JSFiddle - React, Tailwind, and code Playground

by grant

HTML

<div class="container"></div>

CSS

* {
  font-family: 'Roboto', sans-serif;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.title {
  margin: 10px 0 0;
  text-align: center;
}

.container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 1000px;
  gap: 10px;
}

.container img {
  height: 200px;
  width: 200px;
  object-fit: cover;
}

JavaScript

const container = document.querySelector('.container');
const unsplashURL = 'https://source.unsplash.com/random/';
const rows = 1;
// console.log(unsplashURL)
for (let i = 0; i < rows * 1; i++) {
  const img = document.createElement('img');
  img.src = `${unsplashURL}${getRandomSize()}`;
  container.appendChild(img);
}

function getRandomSize() {
  return `${getRandomNumber()}x${getRandomNumber()}`;
}

function getRandomNumber() {
  return Math.floor(Math.random() * 10) + 300;
}