Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Day 69</title>
- <style>
- * {
- padding: 0;
- margin: 0;
- box-sizing: border-box;
- }
- body {
- background: #f4f4f9;
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100vh;
- color: #333;
- }
- img {
- width: 100%;
- height: auto;
- }
- .gallery {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
- gap: 15px;
- max-width: 800px;
- }
- .galleryItem {
- border-radius: 8px;
- overflow: hidden;
- box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
- }
- .galleryItem img {
- width: 100%;
- height: 100%;
- -o-object-fit: cover;
- object-fit: cover;
- cursor: pointer;
- transition: 0.3s ease-in-out;
- }
- .galleryItem:hover img {
- transform: scale(1.1);
- }
- #lightBox {
- display: none;
- align-items: center;
- justify-content: center;
- height: 100vh;
- position: fixed;
- left: 0;
- top: 0;
- background: rgba(0, 0, 0, 0.9);
- width: 100%;
- flex-direction: column;
- }
- #lightBox img {
- width: 90%;
- max-width: 560px;
- height: 80%;
- max-height: 500px;
- border-radius: 8px;
- -o-object-fit: cover;
- object-fit: cover;
- }
- #lightBox #close {
- position: absolute;
- top: 20px;
- right: 30px;
- color: #fff;
- cursor: pointer;
- font-size: 50px;
- }
- #lightBox #caption {
- color: #fff;
- margin-top: 20px;
- font-size: 1.1em;
- text-align: center;
- } /*# sourceMappingURL=style.css.map */
- </style>
- </head>
- <body>
- <div class="gallery">
- <div class="galleryItem">
- <img src="https://media.tenor.com/_zWYqfZdneIAAAAM/shocked-face-shocked-meme.gif" alt="Imagem 1" />
- </div>
- <div class="galleryItem">
- <img src="https://www.bu.edu/files/2024/12/Screenshot-2024-12-13-at-12.42.40%E2%80%AFPM.png" alt="Imagem 2" />
- </div>
- <div class="galleryItem">
- <img src="https://ichef.bbci.co.uk/images/ic/480xn/p0kbsfp5.jpg" alt="Imagem 3" />
- </div>
- </div>
- <div id="lightBox">
- <span id="close">×</span>
- <img src="img/06.avif" alt="" id="lightBoxCon">
- <div id="caption">Image</div>
- </div>
- <script>
- const galleryItems = document.querySelectorAll('.galleryItem img');
- const lightBox = document.getElementById('lightBox');
- const lightBoxImg = document.getElementById('lightBoxCon');
- const caption = document.getElementById('caption');
- const close = document.getElementById('close');
- galleryItems.forEach(item => {
- item.addEventListener('click', ()=>{
- lightBox.style.display = 'flex';
- lightBoxImg.src = item.src;
- caption.innerText = item.alt;
- })
- close.addEventListener('click', (e)=>{
- lightBox.style.display = 'none';
- })
- lightBox.addEventListener('click', (e)=>{
- if(e.target !== lightBoxImg && e.target !== caption){
- lightBox.style.display = 'none';
- }
- })
- })
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment