Random image generator
This commit is contained in:
parent
9a25d6022f
commit
d82e9010e1
15
random-image-generator/index.html
Normal file
15
random-image-generator/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!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="style.css" />
|
||||
<title>Random Image Feed</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Random Image Feed</h1>
|
||||
<div class="container"></div>
|
||||
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
17
random-image-generator/script.js
Normal file
17
random-image-generator/script.js
Normal file
@ -0,0 +1,17 @@
|
||||
const container = document.querySelector('.container')
|
||||
const unsplashURL = 'https://source.unsplash.com/random/'
|
||||
const rows = 5
|
||||
|
||||
for(let i = 0; i < rows * 3; i++) {
|
||||
const img = document.createElement('img')
|
||||
img.src = `${unsplashURL}${getRandomSize()}`
|
||||
container.appendChild(img)
|
||||
}
|
||||
|
||||
function getRandomSize() {
|
||||
return `${getRandomNr()}x${getRandomNr()}`
|
||||
}
|
||||
|
||||
function getRandomNr() {
|
||||
return Math.floor(Math.random() * 10) + 300
|
||||
}
|
36
random-image-generator/style.css
Normal file
36
random-image-generator/style.css
Normal file
@ -0,0 +1,36 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Roboto', sans-serif;
|
||||
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;
|
||||
}
|
||||
|
||||
.container img {
|
||||
object-fit: cover;
|
||||
margin: 10px;
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
max-width: 100%;
|
||||
}
|
Loading…
Reference in New Issue
Block a user