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 #11</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="carousel">
<button type="button" id='right' class='right' name="button">
<svg version="1.1" id="right-arrow" width='40px' height='40px ' xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175"
style="enable-background:new 0 0 477.175 477.175;" xml:space="preserve">
<g>
<path style='fill: #dddddd;' d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5
c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z
" />
</g>
</svg>
</button>
<button type="button" id='left' class='left' name="button">
<svg version="1.1" id="left-arrow" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175"
style="enable-background:new 0 0 477.175 477.175;" xml:space="preserve">
<g>
<path style='fill: #dddddd;' d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225
c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z" />
</g>
</svg>
</button>
<svg id='svg2' class='circle-transition' xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle id='circle1' class='circle1 step' cx="34px" cy="49%" r="20" />
<circle id='circle2' class='circle2 step' cx="34px" cy="49%" r="100" />
<circle id='circle3' class='circle3 step' cx="34px" cy="49%" r="180" />
<circle id='circle4' class='circle4 step' cx="34px" cy="49%" r="260" />
<circle id='circle5' class='circle5 step' cx="34px" cy="49%" r="340" />
<circle id='circle6' class='circle6 step' cx="34px" cy="49%" r="420" />
<circle id='circle7' class='circle7 step' cx="34px" cy="49%" r="500" />
<circle id='circle8' class='circle8 step' cx="34px" cy="49%" r="580" />
<circle id='circle9' class='circle9 step' cx="34px" cy="49%" r="660" />
</svg>
<svg id='svg1' class='circle-transition' xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<circle id='circle10' class='circle10 step' cx="648px" cy="49%" r="20" />
<circle id='circle11' class='circle11 step' cx="648px" cy="49%" r="100" />
<circle id='circle12' class='circle12 step' cx="648px" cy="49%" r="180" />
<circle id='circle13' class='circle13 step' cx="648px" cy="49%" r="260" />
<circle id='circle14' class='circle14 step' cx="648px" cy="49%" r="340" />
<circle id='circle15' class='circle15 step' cx="648px" cy="49%" r="420" />
<circle id='circle16' class='circle16 step' cx="648px" cy="49%" r="500" />
<circle id='circle17' class='circle17 step' cx="648px" cy="49%" r="580" />
<circle id='circle18' class='circle18 step' cx="648px" cy="49%" r="660" />
</svg>
<div class="slide active" id="slide1">Title 1</div>
<div class="slide" id="slide2">Title 2</div>
<div class="slide" id="slide3">Title 3</div>
</div>
</div>
<script src="index.js"></script>
</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: #dcf8ef;
background-image: radial-gradient(#dcf8ef, #fee2f8);
}
.container {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 384px;
width: 680px;
margin: auto;
border-radius: 16px;
box-shadow: 0 0 75px 5px rgba(0, 0, 0, 0.25);
overflow: hidden;
}
.carousel {
position: absolute;
display: inline-flex;
width: 400%;
height: 100%;
background: #000;
overflow: hidden;
}
button {
position: absolute;
height: 40px;
width: 40px;
background: #fff;
box-shadow: 0 0 75px 5px rgba(0, 0, 0, 0.75);
z-index: 50;
border: none;
border-radius: 50%;
cursor: pointer;
overflow: hidden;
}
button:focus {
outline-width: 0;
}
svg {
position: absolute;
height: 384px;
width: 680px;
z-index: 1;
}
circle {
stroke: #fff;
fill: none;
transition: 0.25s;
}
#svg1 circle, #svg2 circle {
transition-timing-function: linear;
}
#right-arrow, #left-arrow {
position: absolute;
height: 16px;
width: 16px;
}
#right-arrow {
transform: translate(-7px, -8px);
}
#left-arrow {
transform: translate(-9px, -8px);
}
.right, .left {
background-color: transparent;
border: 1px solid #777;
margin-top: 168px;
transition: 0.5s all;
}
.right {
margin-left: 628px;
}
.right:hover, .left:hover {
background-color: #aaa;
}
.left {
margin-left: 0.5%;
}
.circle1 {
transition-delay: 0.05s;
}
.circle2 {
transition-delay: 0.1s;
}
.circle3 {
transition-delay: 0.15s;
}
.circle4 {
transition-delay: 0.2s;
}
.circle5 {
transition-delay: 0.25s;
}
.circle6 {
transition-delay: 0.3s;
}
.circle7 {
transition-delay: 0.35s;
}
.circle8 {
transition-delay: 0.4s;
}
.circle9 {
transition-delay: 0.45s;
}
.circle10 {
transition-delay: 0.05s;
}
.circle11 {
transition-delay: 0.1s;
}
.circle12 {
transition-delay: 0.15s;
}
.circle13 {
transition-delay: 0.2s;
}
.circle14 {
transition-delay: 0.25s;
}
.circle15 {
transition-delay: 0.3s;
}
.circle16 {
transition-delay: 0.35s;
}
.circle17 {
transition-delay: 0.4s;
}
.circle18 {
transition-delay: 0.45s;
}
.step {
stroke-width: 0;
}
.slide {
position: absolute;
height: 100%;
width: 25%;
color: #fff;
background-position: center;
background-size: cover;
padding-top: 138px;
font-size: 62px;
font-weight: 800;
font-family: serif;
text-align: center;
z-index: 10;
transition: all 0.5s;
}
#slide1 {
background-image: url("https://images.unsplash.com/photo-1597989139254-04e6df893f36?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1604&q=80");
}
#slide2 {
background-image: url("https://images.unsplash.com/photo-1490977578991-7cbc98568677?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80");
}
#slide3 {
background-image: url("https://images.unsplash.com/photo-1621855046962-09a16702588e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1451&q=80");
}
.transition-effect {
opacity: 0.25;
transform: scale3d(1.1, 0.9, 1);
}
.active {
z-index: 20;
}
.circle-transition {
z-index: 40;
}
.streak {
stroke-width: 82px;
}
Below is the javascript code for this video.
index.js
var currentPage = 1;
var sliding = false;
var click = true;
var left = document.getElementById("left");
var right = document.getElementById("right");
var pagePrefix = "slide";
var pageShift = 500;
var transitionPrefix = "circle";
var svg = true;
function leftSlide() {
if (click) {
if (currentPage == 1)
currentPage = 4;
sliding = true;
currentPage--;
svg = true;
click = false;
for (k = 1; k < 4; k++) {
var a1 = document.getElementById(pagePrefix + k);
a1.className += " transition-effect";
}
setTimeout(() => move(), 200);
setTimeout(() => {
for (k = 1; k < 4; k++) {
var a1 = document.getElementById(pagePrefix + k);
a1.classList.remove("transition-effect");
}
}, 1400);
}
}
function rightSlide() {
if (click) {
if (currentPage == 3)
currentPage = 0;
sliding = true;
currentPage++;
svg = false;
click = false;
for (k = 1; k < 4; k++) {
var a1 = document.getElementById(pagePrefix + k);
a1.className += " transition-effect";
}
setTimeout(() => move(), 200);
setTimeout(() => {
for (k = 1; k < 4; k++) {
var a1 = document.getElementById(pagePrefix + k);
a1.classList.remove("transition-effect");
}
}, 1400);
}
}
function move() {
if (sliding) {
sliding = false;
if (svg)
for (j = 1; j <= 9; j++) {
var c = document.getElementById(transitionPrefix + j);
c.classList.remove("step");
c.setAttribute("class", transitionPrefix + j + " streak");
}
else
for (j = 10; j <= 18; j++) {
var c = document.getElementById(transitionPrefix + j);
c.classList.remove("step");
c.setAttribute("class", transitionPrefix + j + " streak");
}
setTimeout(() => {
for (i = 1; i <= 4; i++) {
if (i == currentPage) {
var a = document.getElementById(pagePrefix + i);
a.className += " active";
} else {
var b = document.getElementById(pagePrefix + i);
b.classList.remove("active");
}
}
sliding = true;
}, 600);
setTimeout(() => click = true, 1700);
setTimeout(() => {
if (svg)
for (j = 1; j <= 9; j++) {
var c = document.getElementById(transitionPrefix + j);
c.classList.remove("streak");
c.setAttribute("class", transitionPrefix + j + " step");
}
else {
for (j = 10; j <= 18; j++) {
var c = document.getElementById(transitionPrefix + j);
c.classList.remove("streak");
c.setAttribute("class", transitionPrefix + j + " step");
}
sliding = true;
}
}, 850);
setTimeout(() => click = true, 1700);
}
}
left.onmousedown = () => leftSlide();
right.onmousedown = () => rightSlide();
document.onkeydown = e => {
if (e.keyCode == 37)
leftSlide();
else if (e.keyCode == 39)
rightSlide();
};
Thanks for visiting