-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path14.html
More file actions
66 lines (59 loc) · 1.66 KB
/
Copy path14.html
File metadata and controls
66 lines (59 loc) · 1.66 KB
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
<!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>
<style>
.gallery {
display: flex;
flex-wrap: wrap;
}
.gallery img {
max-width: 100%;
margin: 10px;
cursor: pointer;
}
.lightbox {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
justify-content: center;
align-items: center;
}
.lightbox img {
max-width: 80%;
max-height: 80%;
}
</style>
</head>
<body>
<h1>Image Gallery</h1>
<div class="gallery">
<img src="image1.jpeg" alt="Image 1">
<img src="image2.jpeg" alt="Image 2">
<img src="image3.jpeg" alt="Image 3">
</div>
<div class="lightbox" id="lightbox">
<img id="lightboxImage" src="" alt="Lightbox Image">
</div>
<script>
const gallery = document.querySelector('.gallery');
const lightbox = document.getElementById('lightbox');
const lightboxImage = document.getElementById('lightboxImage');
gallery.addEventListener('click', (event) => {
if (event.target.tagName === 'IMG') {
lightboxImage.src = event.target.src;
lightbox.style.display = 'flex';
}
});
lightbox.addEventListener('click', () => {
lightbox.style.display = 'none';
});
</script>
</body>
</html>