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 #9</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="carousel">
<input type="checkbox" class="slide-input" id="slide5">
<div class="slide" slide-no="5" slide-title="Fifth slide title.">
<img src="https://images.unsplash.com/photo-1621267706561-db2391442e63?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80"
alt="Slide 5">
</div>
<input type="checkbox" class="slide-input" id="slide4">
<div class="slide" slide-no="4" slide-title="Fourth slide title.">
<img src="https://images.unsplash.com/photo-1633933061665-bdd0f626e59c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="Slide 4">
</div>
<input type="checkbox" class="slide-input" id="slide3">
<div class="slide" slide-no="3" slide-title="Third slide title.">
<img src="https://images.unsplash.com/photo-1519929436393-fe843baf2cec?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80"
alt="Slide 3">
</div>
<input type="checkbox" class="slide-input" id="slide2">
<div class="slide" slide-no="2" slide-title="Second slide title.">
<img src="https://images.unsplash.com/photo-1538099023053-30e7da644196?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="Slide 2">
</div>
<input type="checkbox" class="slide-input" id="slide1">
<div class="slide" slide-no="1" slide-title="First slide title.">
<img src="https://images.unsplash.com/photo-1510563800743-aed236490d08?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2940&q=80"
alt="Slide 1">
</div>
<div class="slide-no" count="5"> / 5</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: #009ffd;
background: linear-gradient(to bottom, #009ffd, #2a2a72);
}
.carousel {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 75%;
width: 62.5%;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}
.carousel:hover .slide::after, .carousel:hover .slide-no, .carousel:hover .slide::before {
opacity: 1;
}
.slide {
position: absolute;
height: 100%;
width: 100%;
background-color: #dddddd;
float: right;
text-align: center;
opacity: 1;
transition: opacity 0.5s;
z-index: 1;
}
.slide::before {
content: attr(slide-title);
position: absolute;
left: 20px;
bottom: 20px;
display: block;
color: #ffffff;
font-size: 14px;
font-weight: 300;
text-shadow: 0 0 1px #000000;
opacity: 0;
transition: opacity 0.25s;
z-index: 12;
}
.slide::after {
content: attr(slide-no);
position: absolute;
bottom: 0;
display: block;
height: 100px;
width: 100%;
background-image: linear-gradient(to bottom, transparent, #000000BF);
color: #ffffff;
text-align: left;
font-size: 13px;
text-indent: 94.75%;
line-height: 141px;
text-shadow: 0 0 1px #000000;
opacity: 0;
transition: opacity 0.25s;
}
.slide img {
height: 100%;
width: 100%;
object-fit: fill;
}
.slide-no {
position: absolute;
bottom: 20px;
right: 1px;
height: 20px;
width: 60px;
z-index: 2;
text-align: center;
color: #ffffff;
line-height: 21px;
font-size: 13px;
opacity: 0;
transition: opacity 0.25s;
}
.slide-input {
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 100%;
float: right;
margin-top: 0;
z-index: 9;
cursor: pointer;
opacity: 0;
}
.slide-input:checked {
z-index: 8;
}
.slide-input:checked+.slide {
opacity: 0;
}
.slide-input:checked:nth-child(1):checked {
z-index: 9;
}
.slide-input:nth-child(1):checked {
float: left;
z-index: 9;
}
.slide-input:nth-child(1):checked+.slide {
opacity: 1;
}
.slide-input:nth-child(1):checked~.slide-input {
float: left;
z-index: 8;
}
.slide-input:nth-child(1):checked~.slide-input+.slide {
opacity: 0;
}
.slide-input:nth-child(1):checked~.slide-input:checked {
z-index: 9;
}
.slide-input:nth-child(1):checked~.slide-input:checked+.slide {
opacity: 1;
}
Thanks for visiting