Skip to content

Commit 3450588

Browse files
authored
Day 48, Random Img looker
1 parent 3c93f17 commit 3450588

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

project 48/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="style.css" />
7+
<title>Random Image Feed</title>
8+
</head>
9+
<body>
10+
<h1 class="title">Random Image Feed</h1>
11+
<div class="container"></div>
12+
13+
<script src="script.js"></script>
14+
</body>
15+
</html>

project 48/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const container = document.querySelector(".container");
2+
const unsplashURL = "https://source.unsplash.com/random/";
3+
const rows = 5;
4+
5+
for (let i = 0; i < rows * 3; i++) {
6+
const img = document.createElement("img");
7+
img.src = `${unsplashURL}${getRandomSize()}`;
8+
container.appendChild(img);
9+
}
10+
11+
function getRandomSize() {
12+
return `${getRandomNr()}x${getRandomNr()}`;
13+
}
14+
15+
function getRandomNr() {
16+
return Math.floor(Math.random() * 10) + 300;
17+
}

project 48/style.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
2+
3+
* {
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
font-family: 'Roboto', sans-serif;
9+
display: flex;
10+
flex-direction: column;
11+
align-items: center;
12+
justify-content: center;
13+
min-height: 100vh;
14+
margin: 0;
15+
}
16+
17+
.title {
18+
margin: 10px 0 0;
19+
text-align: center;
20+
}
21+
22+
.container {
23+
display: flex;
24+
align-items: center;
25+
justify-content: center;
26+
flex-wrap: wrap;
27+
max-width: 1000px;
28+
}
29+
30+
.container img {
31+
object-fit: cover;
32+
margin: 10px;
33+
height: 300px;
34+
width: 300px;
35+
max-width: 100%;
36+
}

0 commit comments

Comments
 (0)