The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE 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>Horizontal Image Carousel #6</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="carousel">
<input type="radio" name="carousel" id="carousel1" class="carousel-input" hidden checked>
<div class="slide">
<img src="https://images.unsplash.com/photo-1529485726363-95c8d62f656f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1374&q=80"
alt="image 1">
</div>
<input type="radio" name="carousel" id="carousel2" class="carousel-input" hidden>
<div class="slide">
<img src="https://images.unsplash.com/photo-1604908177453-7462950a6a3b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1357&q=80"
alt="image 2">
</div>
<input type="radio" name="carousel" id="carousel3" class="carousel-input" hidden>
<div class="slide">
<img src="https://images.unsplash.com/photo-1483909796554-bb0051ab60ad?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1473&q=80"
alt="image 3">
</div>
<label for="carousel3" class="carousel-control prev control1"><</label>
<label for="carousel2" class="carousel-control next control1">></label>
<label for="carousel1" class="carousel-control prev control2"><</label>
<label for="carousel3" class="carousel-control next control2">></label>
<label for="carousel2" class="carousel-control prev control3"><</label>
<label for="carousel1" class="carousel-control next control3">></label>
<ul class="carousel-indicators">
<li><label for="carousel1" class="carousel-bullet">◉</label></li>
<li><label for="carousel2" class="carousel-bullet">◉</label></li>
<li><label for="carousel3" class="carousel-bullet">◉</label></li>
</ul>
</div>
</div>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
height: 100vh;
width: 100%;
background-color: #777777;
}
.container {
height: 100vh;
width: 100%;
}
.carousel {
height: 100%;
width: 100%;
overflow: hidden;
}
.carousel-input:checked+.slide {
position: static;
opacity: 1;
}
.slide {
position: relative;
height: 100%;
width: 100%;
opacity: 0;
transition: opacity 0.5s ease-in-out;
}
.slide img {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 100%;
width: 100%;
object-fit: fill;
}
.carousel-control {
position: absolute;
top: 50%;
transform: translateY(-50%);
height: 40px;
width: 40px;
background: rgba(127, 127, 127, 0.25);
border-radius: 50%;
color: #dddddd;
font-size: 32px;
line-height: 35px;
text-align: center;
cursor: pointer;
z-index: 2;
display: none;
}
.carousel-control.prev {
left: 2%;
}
.carousel-control.next {
right: 2%;
}
.carousel-control:hover {
background-color: rgba(127, 127, 127, 0.75);
color: #ffffff;
}
#carousel1:checked~.control1,
#carousel2:checked~.control2,
#carousel3:checked~.control3 {
display: block;
}
#carousel1:checked~.control1~.carousel-indicators li:nth-child(1) .carousel-bullet,
#carousel2:checked~.control1~.carousel-indicators li:nth-child(2) .carousel-bullet,
#carousel3:checked~.control1~.carousel-indicators li:nth-child(3) .carousel-bullet {
color: #ffffff;
}
.carousel-indicators {
position: absolute;
left: 0;
right: 0;
bottom: 2%;
list-style: none;
z-index: 2;
text-align: center;
}
.carousel-indicators li {
display: inline-block;
margin: 0 1%;
}
.carousel-indicators li:first-child {
margin-left: 0;
}
.carousel-indicators li:last-child {
margin-right: 0;
}
.carousel-bullet {
display: block;
font-size: 28px;
color: #777777;
cursor: pointer;
}
.carousel-bullet:hover {
color: #aaaaaa;
}
Thanks for visiting