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 #10</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="bg-image-container">
<img width="100%" height="100%" id="bg-image">
</div>
<div class="slide" id="slide1">
<img src="https://images.unsplash.com/photo-1476485010923-08421403348c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="img 1">
</div>
<div class="slide" id="slide2">
<img src="https://images.unsplash.com/photo-1572043464204-a36047e9c446?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="img 2">
</div>
<div class="slide" id="slide3">
<img src="https://images.unsplash.com/photo-1532680678473-a16f2cda8e43?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80"
alt="img 3">
</div>
<div class="slide" id="slide4">
<img src="https://images.unsplash.com/photo-1621360841013-c7683c659ec6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1632&q=80"
alt="img 4">
</div>
<div class="slide" id="slide5">
<img src="https://images.unsplash.com/photo-1532617023409-df97577298d9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80"
alt="img 5">
</div>
<div class="prev-btn-container">
<button class="prev-btn" id="prev-btn" onclick="change(this.id)"> < </button>
</div>
<div class="next-btn-container">
<button class="next-btn" id="next-btn" onclick="change(this.id)"> > </button>
</div>
<div class="title-text-container" id="title-text-container">
<p id="title-text"></p>
</div>
<div class="description-text-container" id="description-text-container">
<p id="description-text"></p>
</div>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background-color: #90D5EC;
background-image: linear-gradient(45deg, #90D5EC, #FC575E);
color: #ffffff;
overflow: hidden;
}
.bg-image-container {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.bg-image-container img {
filter: blur(5px);
opacity: 0.75;
}
.slide {
position: absolute;
background-color: #000000;
border-radius: 8px;
width: 25%;
height: 40%;
display: none;
transition: all 0.75s;
transition-timing-function: cubic-bezier(0.25, 1, 0.5, 1);
box-shadow: 0 5px 20px 5px #000;
}
.slide img {
height: 100%;
width: 100%;
object-fit: fill;
}
.prev-btn-container, .next-btn-container {
position: absolute;
top: 43%;
z-index: 2;
}
.prev-btn-container {
left: 21%;
}
.next-btn-container {
left: 78%;
}
.prev-btn, .next-btn {
font-weight: 900;
border: none;
background-color: transparent;
font-size: 32px;
color: #ffffff;
transition: all 0.5s;
}
.prev-btn:hover, .next-btn:hover {
transform: scale(2);
}
.title-text-container, .description-text-container {
position: absolute;
left: 50%;
transition: all 0.75s;
transition-timing-function: cubic-bezier(0.25, 0.75, 0.5, 1);
opacity: 0;
text-shadow: 2px 2px #000000;
}
.title-text-container {
top: 80%;
transform: translate(-50%, -80%);
}
.title-text-container p {
font-size: 48px;
font-family: fantasy;
}
.description-text-container {
top: 85%;
transform: translate(-50%, -85%);
}
.description-text-container p {
font-size: 16px;
font-family: monospace;
}
Below is the javascript code for this video.
index.js
var middleFrame = 2;;
var totalFrames = 5;
var titles = ["Title 1", "Title 2", "Title 3", "Title 4", "Title 5"];
var descriptions = ["Description 1", "Description 2", "Description 3", "Description 4", "Description 5"];
var images = [
"https://images.unsplash.com/photo-1476485010923-08421403348c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80",
"https://images.unsplash.com/photo-1572043464204-a36047e9c446?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80",
"https://images.unsplash.com/photo-1532680678473-a16f2cda8e43?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80",
"https://images.unsplash.com/photo-1621360841013-c7683c659ec6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1632&q=80",
"https://images.unsplash.com/photo-1532617023409-df97577298d9?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1471&q=80"
];
function setUI() {
for (var i = 1; i <= totalFrames; i++) {
document.getElementById("slide" + i).style.display = "none";
}
var middleImageContainer, prevImageContainer, nextImageContainer;
middleImageContainer = document.getElementById("slide" + middleFrame);
middleImageContainer.style.top = "45%";
middleImageContainer.style.left = "50%";
middleImageContainer.style.transform = "translate(-50%, -50%)";
middleImageContainer.style.display = "block";
middleImageContainer.style.height = "40%";
middleImageContainer.style.width = "33%";
middleImageContainer.style.opacity = "1";
middleImageContainer.style.zIndex = "1";
if (middleFrame != 1) {
prevImageContainer = document.getElementById("slide" + (middleFrame - 1));
prevImageContainer.style.top = "30%";
prevImageContainer.style.left = "10%";
prevImageContainer.style.transform = "perspective(500px) rotateY(45deg)";
prevImageContainer.style.display = "block";
prevImageContainer.style.height = "30%";
prevImageContainer.style.width = "25%";
prevImageContainer.style.opacity = "0.33";
}
if (middleFrame != totalFrames) {
nextImageContainer = document.getElementById("slide" + (middleFrame + 1));
nextImageContainer.style.top = "30%";
nextImageContainer.style.left = "65%";
nextImageContainer.style.transform = "perspective(500px) rotateY(-45deg)";
nextImageContainer.style.display = "block";
nextImageContainer.style.height = "30%";
nextImageContainer.style.width = "25%";
nextImageContainer.style.opacity = "0.33";
}
document.getElementById("bg-image").src = images[middleFrame - 1];
document.getElementById("title-text-container").style.top = "90%";
document.getElementById("title-text-container").style.opacity = "0";
document.getElementById("description-text-container").style.top = "95%";
document.getElementById("description-text-container").style.opacity = "0";
setTimeout(function () {
document.getElementById("title-text-container").style.top = "80%";
document.getElementById("title-text-container").style.opacity = "1";
document.getElementById("title-text").innerHTML = titles[middleFrame - 1];
}, 750);
setTimeout(function () {
document.getElementById("description-text-container").style.top = "85%";
document.getElementById("description-text-container").style.opacity = "1";
document.getElementById("description-text").innerHTML = descriptions[middleFrame - 1];
}, 1000);
}
setUI();
function change(id) {
document.getElementById("prev-btn").style.display = "block";
document.getElementById("next-btn").style.display = "block";
if (id == "prev-btn") {
middleFrame--;
} else if (id == "next-btn") {
middleFrame++;
}
if (middleFrame == 1) {
document.getElementById("prev-btn").style.display = "none";
} else if (middleFrame == totalFrames) {
document.getElementById("next-btn").style.display = "none";
}
setUI();
}
Thanks for visiting