Add files via upload
This commit is contained in:
parent
979c97d087
commit
a8210e6f42
BIN
100_projects/40-carousel-image-vanilla-js/01.avif
Normal file
BIN
100_projects/40-carousel-image-vanilla-js/01.avif
Normal file
Binary file not shown.
BIN
100_projects/40-carousel-image-vanilla-js/02.avif
Normal file
BIN
100_projects/40-carousel-image-vanilla-js/02.avif
Normal file
Binary file not shown.
BIN
100_projects/40-carousel-image-vanilla-js/03.avif
Normal file
BIN
100_projects/40-carousel-image-vanilla-js/03.avif
Normal file
Binary file not shown.
BIN
100_projects/40-carousel-image-vanilla-js/04.avif
Normal file
BIN
100_projects/40-carousel-image-vanilla-js/04.avif
Normal file
Binary file not shown.
20
100_projects/40-carousel-image-vanilla-js/index.html
Normal file
20
100_projects/40-carousel-image-vanilla-js/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Carousel</title>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<script src="script.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="carousel">
|
||||
<div class="image-container" id="imgs">
|
||||
<img src="01.avif"alt=""/>
|
||||
<img src="02.avif"alt=""/>
|
||||
<img src="03.avif"alt=""/>
|
||||
<img src="04.avif"alt=""/>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
14
100_projects/40-carousel-image-vanilla-js/script.js
Normal file
14
100_projects/40-carousel-image-vanilla-js/script.js
Normal file
@ -0,0 +1,14 @@
|
||||
const imgs = document.getElementById("imgs");
|
||||
const img = document.querySelectorAll("#imgs img");
|
||||
|
||||
let index = 0;
|
||||
|
||||
function run() {
|
||||
index++;
|
||||
|
||||
if (index > img.length - 1) {
|
||||
index = 0;
|
||||
}
|
||||
imgs.style.transform = `translateX(${-index * 500}px)`;
|
||||
}
|
||||
setInterval(run, 2000);
|
28
100_projects/40-carousel-image-vanilla-js/style.css
Normal file
28
100_projects/40-carousel-image-vanilla-js/style.css
Normal file
@ -0,0 +1,28 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: "Poppins", sans-serif;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: #E6E6FA;
|
||||
}
|
||||
.carousel {
|
||||
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
|
||||
overflow: hidden;
|
||||
height: 500px;
|
||||
width: 350px;
|
||||
}
|
||||
.image-container {
|
||||
display: flex;
|
||||
transition: transform 0.5s ease-in-out;
|
||||
transform: translateX(0);
|
||||
}
|
||||
img {
|
||||
object-fit: cover;
|
||||
height: 500px;
|
||||
width: 500px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user