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>Animated Vertical Tabs</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="left-container">
<ul>
<li class="tab1 active">Tab 1</li>
<li class="tab2">Tab 2</li>
<li class="tab3">Tab 3</li>
<li class="tab4">Tab 4</li>
</ul>
</div>
<div class="border">
<div class="one" id="line"></div>
</div>
<div class="right-container">
<div class="active" id="first-tab">
<h2>Heading Tab 1</h2>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Possimus rerum ipsam illo ut consequuntur
quod sed officia laboriosam repellendus maxime praesentium id, necessitatibus, expedita corporis, ab
ullam temporibus eius quam!</p>
</div>
<div id="second-tab">
<h2>Heading Tab 2</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda ab at quae pariatur molestias
excepturi. Saepe assumenda magni ducimus dicta praesentium provident atque! Repudiandae assumenda
minus fuga atque iusto eligendi?</p>
</div>
<div id="third-tab">
<h2>Heading Tab 3</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni excepturi nisi, nam non labore cumque
tempora molestiae et, voluptate eius laborum illum quis rem quibusdam porro? Dolorum similique magni
minus.</p>
</div>
<div id="forth-tab">
<h2>Heading Tab 4</h2>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Nihil quod odit adipisci exercitationem
minus ex vel possimus earum, enim mollitia accusantium fugiat natus nisi vero soluta officia, eius
praesentium unde.</p>
</div>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
@import url('https://fonts.googleapis.com/css2?family=Poiret+One&display=swap');
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background-color: #0f0f0f;
color: #f0f0f0;
font-family: 'Poiret One', cursive;
overflow: hidden;
}
ul, li {
list-style: none;
}
.container {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
height: 55%;
width: 73%;
background-color: #0f0f0f;
border-radius: 32px;
align-items: center;
justify-content: left;
margin: auto;
overflow: hidden;
animation: swappingShadow 5.5s ease infinite;
}
@keyframes swappingShadow {
0%, 100% {
box-shadow: 32px 32px 64px 0 #00336680, inset -8px -8px 16px 0 #003366bf, inset 0 11px 22px 0 #551a8b,
-32px -32px 64px 0 #551a8b80, inset 8px 8px 16px 0 #551a8bbf, inset 0 -11px 22px 0 #003366;
}
50% {
box-shadow: -32px -32px 64px 0 #00336680, inset 8px 8px 16px 0 #003366bf, inset 0 -11px 22px 0 #551a8b,
32px 32px 64px 0 #551a8b80, inset -8px -8px 16px 0 #551a8bbf, inset 0 11px 22px 0 #003366;
}
}
.left-container {
display: flex;
height: 75%;
width: 25%;
align-items: center;
justify-content: center;
}
.left-container ul li {
display: flex;
color: #f0f0f080;
font-weight: 600;
margin: 99% 0;
cursor: pointer;
transition: all 0.25s ease-in-out;
}
.left-container ul li.active, .left-container ul li.active:hover {
color: #f0f0f0;
transform: scale(1.15);
cursor: default;
}
.left-container ul li:hover {
color: #f0f0f0bf;
transform: scale(1.25);
}
.border {
height: 73%;
width: 1px;
background-color: #f0f0f080;
}
.border #line {
height: 55px;
width: 5px;
background-color: #2b2779;
margin-left: -2px;
transition: all 0.5s ease-in-out;
}
.border #line.one {
margin-top: 35px;
}
.border #line.two {
margin-top: 92px;
}
.border #line.three {
margin-top: 152px;
}
.border #line.four {
margin-top: 210px;
}
.right-container {
height: 75%;
width: 75%;
}
.right-container #first-tab, .right-container #second-tab, .right-container #third-tab, .right-container #forth-tab {
position: absolute;
display: flex;
flex-direction: column;
height: 75%;
width: 75%;
margin-top: -75%;
align-items: center;
justify-content: center;
opacity: 0;
transition: all 0.75s ease-in-out;
}
h2 {
font-weight: 800;
line-height: 2;
padding-right: 15px;
}
p {
font-weight: 600;
text-align: justify;
line-height: 1.5;
padding: 0 30px 0 45px;
}
.right-container #first-tab.active, .right-container #second-tab.active, .right-container #third-tab.active, .right-container #forth-tab.active {
margin-top: 0;
opacity: 1;
transition: all 0.75s ease-in-out;
}
Below is the javascript code for this video.
index.js
const firstTab = document.querySelector("#first-tab"), secondTab = document.querySelector("#second-tab"),
thirdTab = document.querySelector("#third-tab"), forthTab = document.querySelector("#forth-tab");
document.querySelector(".tab1").addEventListener("click", function () {
addActiveClass(".tab1"); removeActiveClass(".tab2, .tab3, .tab4"); handleClick("one");
});
document.querySelector(".tab2").addEventListener("click", function () {
addActiveClass(".tab2"); removeActiveClass(".tab1, .tab3, .tab4"); handleClick("two");
});
document.querySelector(".tab3").addEventListener("click", function () {
addActiveClass(".tab3"); removeActiveClass(".tab2, .tab1, .tab4"); handleClick("three");
});
document.querySelector(".tab4").addEventListener("click", function () {
addActiveClass(".tab4"); removeActiveClass(".tab2, .tab3, .tab1"); handleClick("four");
});
const addActiveClass = (selector) => document.querySelectorAll(selector).forEach((element) => element.classList.add("active"));
const removeActiveClass = (selector) => document.querySelectorAll(selector).forEach((element) => element.classList.remove("active"));
const handleClick = (selector) => {
document.querySelector("#line").classList.remove("one", "two", "three", "four");
document.querySelector("#line").classList.add(selector);
switch (selector) {
case 'one': firstTab.classList.add("active"); secondTab.classList.remove("active");
thirdTab.classList.remove("active"); forthTab.classList.remove("active"); break;
case 'two': firstTab.classList.remove("active"); secondTab.classList.add("active");
thirdTab.classList.remove("active"); forthTab.classList.remove("active"); break;
case 'three': firstTab.classList.remove("active"); secondTab.classList.remove("active");
thirdTab.classList.add("active"); forthTab.classList.remove("active"); break;
case 'four': firstTab.classList.remove("active"); secondTab.classList.remove("active");
thirdTab.classList.remove("active"); forthTab.classList.add("active"); break;
}
}
Thanks for visiting