Skip to content

Commit 91855ce

Browse files
committed
feat: Block Chain Collage Code 1 - 15
Update the main index file
1 parent 6ab2067 commit 91855ce

4 files changed

Lines changed: 129 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
box-sizing: border-box;
5+
list-style: none;
6+
}
7+
8+
.container {
9+
height: 90vh;
10+
position: relative;
11+
overflow: hidden;
12+
}
13+
14+
.container img {
15+
position: absolute;
16+
z-index: 100;
17+
width: 100%;
18+
height: 100%;
19+
object-fit: cover;
20+
opacity: 0;
21+
transition: all 0.5s;
22+
}
23+
24+
.container i {
25+
position: absolute;
26+
padding: 10px;
27+
background-color: rgba(0, 0, 0, 0.4);
28+
border-radius: 50%;
29+
color: white;
30+
font-size: 35px;
31+
z-index: 101;
32+
cursor: pointer;
33+
top: 50%;
34+
transform: translateY(-50%);
35+
}
36+
37+
.container .bx-arrow-left {
38+
left: 5%;
39+
}
40+
41+
.container .bx-arrow-right {
42+
right: 5%;
43+
}
44+
45+
.show {
46+
opacity: 1 !important;
47+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1.0"
8+
/>
9+
<link
10+
href="https://cdn.boxicons.com/fonts/basic/boxicons.min.css"
11+
rel="stylesheet"
12+
/>
13+
<link
14+
rel="stylesheet"
15+
href="css/style.css"
16+
/>
17+
<title>Document</title>
18+
</head>
19+
<body>
20+
<div class="container">
21+
<!-- Images will be injected dynamically -->
22+
<i
23+
class="bx bx-arrow-left"
24+
id="prev"
25+
></i>
26+
<i
27+
class="bx bx-arrow-right"
28+
id="next"
29+
></i>
30+
</div>
31+
32+
<script src="js/script.js"></script>
33+
</body>
34+
</html>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use strict";
2+
3+
const container = document.querySelector(".container");
4+
const nextBtn = document.querySelector("#next");
5+
const prevBtn = document.querySelector("#prev");
6+
7+
let imageEls = [];
8+
let currentIndex = 0;
9+
10+
// Fetch images from Picsum API
11+
fetch("https://picsum.photos/v2/list?page=2&limit=6")
12+
.then(res => res.json())
13+
.then(data => {
14+
// Create <img> elements dynamically
15+
data.forEach((img, index) => {
16+
let image = document.createElement("img");
17+
image.src = img.download_url;
18+
image.alt = "Slider image";
19+
if (index === 0) image.classList.add("show");
20+
container.appendChild(image);
21+
});
22+
23+
// Update NodeList after adding images
24+
imageEls = document.querySelectorAll(".container img");
25+
})
26+
.catch(err => console.error("Error fetching images:", err));
27+
28+
// Next Button
29+
nextBtn.addEventListener("click", () => {
30+
if (imageEls.length === 0) return;
31+
32+
imageEls[currentIndex].classList.remove("show");
33+
currentIndex = (currentIndex === imageEls.length - 1) ? 0 : currentIndex + 1;
34+
imageEls[currentIndex].classList.add("show");
35+
});
36+
37+
// Prev Button
38+
prevBtn.addEventListener("click", () => {
39+
if (imageEls.length === 0) return;
40+
41+
imageEls[currentIndex].classList.remove("show");
42+
currentIndex = (currentIndex === 0) ? imageEls.length - 1 : currentIndex - 1;
43+
imageEls[currentIndex].classList.add("show");
44+
});

Block Chain Collage Code 1/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ <h3>
4343
<a href="13/13.1/index.html">13.1</a>
4444
<a href="13/13.2/index.html">13.2</a>
4545
<a href="13/13.3/index.html">13.3</a>
46+
<a href="14/14.1/index.html">14.1</a>
47+
<a href="14/14.2/index.html">14.2</a>
48+
<a href="14/14.3/index.html">14.3</a>
49+
<a href="15/index.html">15</a>
4650
</div>
4751
<footer>© 2025 Class Repo | MDJAmin</footer>
4852
<script src="../js/script.js"></script>

0 commit comments

Comments
 (0)