-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery.html
108 lines (93 loc) · 3.23 KB
/
gallery.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
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Gallery</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.7/css/swiper.min.css'>
<style>
body {
font-family: Arial, sans-serif;
}
.gallery {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.gallery-item {
width: 200px;
height: 150px;
object-fit: cover;
cursor: pointer;
border: 2px solid #ccc;
border-radius: 5px;
transition: transform 0.2s;
}
.gallery-item:hover {
transform: scale(1.05);
}
.popup {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
}
.popup-content {
max-width: 90%;
max-height: 90%;
}
.close {
position: absolute;
top: 20px;
right: 30px;
font-size: 30px;
font-weight: bold;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<nav style="height: 50px; background:rgb(81, 81, 244); display:flex; align-items:center;">
<a href="./index.html" style="text-decoration: none ; border:2px solid ; font-size:20px; font-weight:bold; background:white; padding: 2px 4px; border-radius:5px;margin-left:50px;">Back</a>
</nav>
<div class="gallery">
<script>
for (let i = 1; i <= 80; i++) {
document.write(`<img src="./${i}.jpg" alt="Image ${i}" class="gallery-item">`);
}
</script>
</div>
<div id="popup" class="popup">
<span class="close">×</span>
<img class="popup-content" id="popup-img">
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const popup = document.getElementById("popup");
const popupImg = document.getElementById("popup-img");
const close = document.getElementsByClassName("close")[0];
document.querySelectorAll(".gallery-item").forEach(item => {
item.addEventListener("click", function() {
popup.style.display = "flex";
popupImg.src = this.src;
});
});
close.addEventListener("click", function() {
popup.style.display = "none";
});
popup.addEventListener("click", function(event) {
if (event.target === popup) {
popup.style.display = "none";
}
});
});
</script>
</body>
</html>