For a minimal version of the required gallery page, you can use HTML, CSS, and JavaScript with some external libraries like jQuery, Masonry, and Lightbox. Below I've provided the code snippets for each.
- First, include the required libraries and styles in the
<head> section:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<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/lightbox2/2.11.3/css/lightbox.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/masonry/4.2.2/masonry.pkgd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/js/lightbox.min.js"></script>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<title>Gallery</title>
</head>
- Add the gallery HTML structure with a link to the home page:
<body>
<div class="container">
<a href="index.html" class="home-link">Home</a>
<div class="grid">
<div class="grid-item">
<a href="path_to_large_image_1.jpg" data-lightbox="gallery" data-title="Description 1">
<img src="path_to_thumbnail_1.jpg" alt="Image 1">
<div class="overlay">
<div class="text">Description 1</div>
</div>
</a>
</div>
<!-- Add more grid-items with the same structure here -->
</div>
</div>
</body>
</html>
- Create a
style.css file and add the styles:
body {
font-family: Arial, sans-serif;
}
.container {
padding: 20px;
}
.home-link {
display: inline-block;
margin-bottom: 20px;
text-decoration: none;
color: #000;
}
.grid {
max-width: 1200px;
margin: 0 auto;
}
.grid-item {
position: relative;
width: 300px;
margin-bottom: 20px;
}
.grid-item img {
width: 100%;
display: block;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.5);
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
}
.grid-item:hover .overlay {
height: 100%;
}
.text {
color: white;
font-size: 20px;
position: absolute;
bottom: 0;
padding: 20px;
text-align: center;
width: 100%;
}
- Create a
script.js file and add the Masonry and Lightbox initialization:
$(document).ready(function() {
$('.grid').masonry({
itemSelector: '.grid-item',
columnWidth: 320,
gutter: 20,
fitWidth: true
});
lightbox.option({
'resizeDuration': 200,
'wrapAround': true
});
});
Replace the image paths and descriptions with your own content, and add more grid items following the same structure. Please note that this is a minimal example, and you may need to adjust the styles and script depending on your specific requirements.