Skip to content

Instantly share code, notes, and snippets.

@Praiseike
Last active March 25, 2024 12:47
Show Gist options
  • Select an option

  • Save Praiseike/cf32550d9d0b88969fe91b913d76c6f9 to your computer and use it in GitHub Desktop.

Select an option

Save Praiseike/cf32550d9d0b88969fe91b913d76c6f9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="main.css">
<title>Document</title>
</head>
<body>
<div class="flex justify-between md:space-x-2 w-fit mx-auto mt-20 flex-col md:flex-row">
<div id="cols" class="w-[300px] border flex flex-col space-y-2">
</div>
<div id="cols" class="w-[300px] border flex flex-col space-y-2">
</div>
<div id="cols" class="w-[300px] border flex flex-col space-y-2">
</div>
</div>
<script>
const cols = document.querySelectorAll('#cols');
let counter = 0;
const heights = [400,500,600,400,500,400];
const getRandomHeight = () => {
const index = Math.floor((Math.random()) * 10) % 4;
return heights[index];
}
const createImage = (src) => {
return Object.assign(document.createElement('img'),{ src: src});
}
cols.forEach((col) => {
for(let i = 0; i < 5; i++){
col.appendChild(createImage(`https://picsum.photos/400/${getRandomHeight()}?sig=${counter}`));
counter ++;
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment