HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Image Slider</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="carousel">
<div class="carousel-content">
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\nature.jpg" alt="pic" />
</div>
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\nature2.jpg" alt="pic" />
</div>
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\nature3.jpg" alt="pic" />
</div>
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\flower.webp" alt="pic" />
</div>
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\nature3.jpg" alt="pic" />
</div>
<div class="carousel-item">
<img src="C:\Users\91940\Pictures\nature.jpg" alt="pic" />
</div>
</div>
</div>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
min-height: 100vh;
background-color: black;
display: flex;
align-items: center;
justify-content: center;
}
.carousel {
width: 400px;
height: 400px;
perspective: 800px;
}
.carousel-content {
position: relative;
width: 100%;
height: 100%;
transform: translateZ(-500px) rotateY(0);
transform-style: preserve-3d;
animation: carousel 10s infinite cubic-bezier(1, 0.015, 0.295, 1.225) forwards;
}
.carousel-item {
width: 100%;
height: 100%;
border-radius: 5px;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
-webkit-box-reflect: below 0px
linear-gradient(transparent, transparent, #00000040);
}
.carousel-item img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 5px;
}
.carousel-item:nth-child(1) {
transform: rotateY(0) translateZ(500px);
}
.carousel-item:nth-child(2) {
transform: rotateY(60deg) translateZ(500px);
}
.carousel-item:nth-child(3) {
transform: rotateY(120deg) translateZ(500px);
}
.carousel-item:nth-child(4) {
transform: rotateY(180deg) translateZ(500px);
}
.carousel-item:nth-child(5) {
transform: rotateY(240deg) translateZ(500px);
}
.carousel-item:nth-child(6) {
transform: rotateY(300deg) translateZ(500px);}
/* Create a carousel animation */
@keyframes carousel {
0%,
8.3% {
transform: translateZ(-500px) rotateY(0);
}
16.6%,
24.9% {
transform: translateZ(-500px) rotateY(-60deg);
}
33.2%,
41.5% {
transform: translateZ(-500px) rotateY(-120deg);
}
49.8%,
58.1% {
transform: translateZ(-500px) rotateY(-180deg);
}
66.4%,
74.7% {
transform: translateZ(-500px) rotateY(-240deg);
}
83%,
91.3% {
transform: translateZ(-500px) rotateY(-300deg);
}
100% {
transform: translateZ(-500px) rotateY(-360deg);
}
}
No comments:
Post a Comment