-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
100 lines (87 loc) · 2.71 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Faker Person Portraits Grid</title>
<link
rel="icon"
href="https://fakerjs.dev/logo.svg"
sizes="any"
type="image/svg+xml"
/>
<style>
body {
margin: 0;
padding: 0;
background-color: #333;
color: #fff;
font-family: Arial, sans-serif;
}
/* Grid container for all images */
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(256px, 1fr));
gap: 10px;
padding: 10px;
}
/* Each image container is positioned relative for the overlay */
.image-container {
position: relative;
overflow: hidden;
}
.image-container img {
width: 100%;
display: block;
}
/* Overlay caption styling */
.overlay {
position: absolute;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
color: #fff;
font-size: 10px;
padding: 2px 4px;
margin: 0;
}
</style>
</head>
<body>
<div class="grid" id="grid"></div>
<script>
// Define the two types and the range of numbers.
const TYPES = ["male", "female"];
const TOTAL_IMAGES = 100; // Numbers 0 to 99
// Base URL for the images.
const BASE_URL =
"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait";
// Get the grid container from the DOM.
const grid = document.getElementById("grid");
// Loop through each type and number to create the image elements.
for (const type of TYPES) {
for (let i = 0; i < TOTAL_IMAGES; i++) {
// Construct the URL and filename text.
const imageUrl = `${BASE_URL}/${type}/512/${i}.jpg`;
const filenameText = `${type}/${i}.jpg`;
// Create a container div for the image and its overlay.
const container = document.createElement("div");
container.className = "image-container";
// Create the image element.
const img = document.createElement("img");
img.src = imageUrl;
img.alt = filenameText;
// Create the overlay element for the filename.
const overlay = document.createElement("div");
overlay.className = "overlay";
overlay.textContent = filenameText;
// Append the image and overlay to the container.
container.appendChild(img);
container.appendChild(overlay);
// Append the container to the grid.
grid.appendChild(container);
}
}
</script>
</body>
</html>