-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
121 lines (113 loc) · 4.34 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Gallery Project with Lightbox & Pagination</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.4/css/lightbox.min.css" rel="stylesheet" />
<style>
.pagination a
{
padding: 8px 16px;
margin: 0 4px;
border: 1px solid #ddd;
border-radius: 5px;
text-decoration: none;
color: #333;
transition: background-color .3s;
}
.pagination a.active
{
background-color: #4CAF50;
color: white;
border-color: #4CAF50;
}
.pagination a:hover:not(.active)
{
background-color: #ddd;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="gallery-title">
<h2>Gallery with Lightbox & Pagination</h2>
</div>
</div>
<div class="row">
<div class="gallery" id="gallery">
<!-- Your images here -->
</div>
</div>
<div class="pagination" id="pagination">
<!-- Pagination controls will be added here -->
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.4/js/lightbox-plus-jquery.min.js"></script>
<script>
const imagesPerPage = 4;
let currentPage = 1;
const images =
[
{ src: 'images/lakeview-elegance.png', title: 'Lakeview Elegance' },
{ src: 'images/skyline-oasis.png', title: 'Skyline Oasis' },
{ src: 'images/villa-verde.png', title: 'Villa Verde' },
{ src: 'images/vista-paradiso.png', title: 'Vista Paradiso' },
// Add more images as needed
{ src: 'images/villa-verde.png', title: 'Villa Verde' },
{ src: 'images/vista-paradiso.png', title: 'Vista Paradiso' },
{ src: 'images/lakeview-elegance.png', title: 'Lakeview Elegance' },
{ src: 'images/skyline-oasis.png', title: 'Skyline Oasis' },
];
function renderGallery()
{
const gallery = document.getElementById('gallery');
gallery.innerHTML = '';
const start = (currentPage - 1) * imagesPerPage;
const end = start + imagesPerPage;
const pageImages = images.slice(start, end);
for (const image of pageImages)
{
gallery.innerHTML += `
<figure class="card">
<a href="${image.src}" data-lightbox="gallery" data-title="${image.title}">
<img src="${image.src}" alt="${image.title} preview">
</a>
</figure>
`;
}
}
function navigateToPage(page)
{
currentPage = page;
renderGallery();
renderPagination();
}
function renderPagination()
{
const pagination = document.getElementById('pagination');
pagination.innerHTML = '';
const pageCount = Math.ceil(images.length / imagesPerPage);
for (let i = 1; i <= pageCount; i++)
{
const pageLink = document.createElement('a');
pageLink.href = '#';
pageLink.innerText = i;
pageLink.onclick = function ()
{
navigateToPage(i);
};
if (currentPage === i)
{
pageLink.classList.add('active');
}
pagination.appendChild(pageLink);
}
}
renderGallery();
renderPagination();
</script>
</body>
</html>