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>Responsive Tabs</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="wrapper">
<div class="title">
<h1>Responsive Tabs</h1>
</div>
<input type="radio" name="tab-radios" id="tab-1-control" class="panel-radios" checked>
<input type="radio" name="tab-radios" id="tab-2-control" class="panel-radios">
<input type="radio" name="tab-radios" id="tab-3-control" class="panel-radios">
<input type="radio" name="tab-radios" id="tab-4-control" class="panel-radios">
<input type="radio" name="tab-radios" id="tab-5-control" class="panel-radios">
<input type="checkbox" name="nav-checkbox" id="nav-control" class="panel-radios">
<ul class="tabs-list">
<label for="nav-control" id="open-nav-label"></label>
<li class="label-for-tab-1">
<label for="tab-1-control" class="panel-label">Tab 1</label>
</li>
<li class="label-for-tab-2">
<label for="tab-2-control" class="panel-label">Tab 2</label>
</li>
<li class="label-for-tab-3">
<label for="tab-3-control" class="panel-label">Tab 3</label>
</li>
<li class="label-for-tab-4">
<label for="tab-4-control" class="panel-label">Tab 4</label>
</li>
<li class="label-for-tab-5">
<label for="tab-5-control" class="panel-label">Tab 5</label>
</li>
<label for="nav-control" id="close-nav-label">close</label>
</ul>
<div class="panels">
<div class="container">
<section class="tab-1">
<main>
<h2>Tab 1 Heading</h2>
<hr>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Consequuntur nihil autem hic
excepturi velit asperiores, maiores, omnis delectus culpa quia voluptas sed dolorum fugiat
sequi! Dolore rem aliquid nam eveniet.</p>
</main>
</section>
<section class="tab-2">
<main>
<h2>Tab 2 Heading</h2>
<hr>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Laborum temporibus odio perferendis
incidunt rem harum voluptates nihil expedita nemo beatae omnis quis, modi sapiente porro
consequatur vitae maiores impedit ratione.</p>
</main>
</section>
<section class="tab-3">
<main>
<h2>Tab 3 Heading</h2>
<hr>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quis id cumque enim, esse corrupti
nemo ducimus inventore cum adipisci. Voluptatibus maiores saepe, nostrum a provident sunt
itaque ipsum officiis ut.</p>
</main>
</section>
<section class="tab-4">
<main>
<h2>Tab 4 Heading</h2>
<hr>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae at aspernatur quidem harum
pariatur, ullam laborum reprehenderit recusandae consectetur impedit dignissimos!
Praesentium nostrum blanditiis quos quas error minima ipsum provident.</p>
</main>
</section>
<section class="tab-5">
<main>
<h2>Tab 5 Heading</h2>
<hr>
<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Repellendus deleniti consequatur
vitae maxime consequuntur accusantium aspernatur a quasi recusandae neque, soluta dicta
culpa aut ipsam minus magni. Eaque, doloremque numquam.</p>
</main>
</section>
</div>
</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: #a484b0;
color: #000000;
font-family: Arial, Helvetica, sans-serif;
overflow: hidden;
}
.wrapper {
position: absolute;
top: 50%;
width: 100%;
transform: translateY(-50%);
}
.title {
width: 100%;
color: #fcf4e7;
font-weight: 900;
text-align: center;
padding: 0 24px 36px;
}
.panel-radios {
display: none;
}
.tabs-list {
list-style: none;
text-align: center;
border-bottom: 1px solid #b0aad3;
}
.panel-label {
display: block;
width: 100%;
background-color: #b0aad3;
color: #ece4de;
cursor: pointer;
transition: all 0.25s ease;
user-select: none;
}
.panel-label:hover {
color: #3a2767;
}
.panels {
background-color: #fcf4e7;
}
.panels .container {
width: 90%;
margin: 0 auto;
}
.panels section main {
max-height: 0;
overflow-y: hidden;
opacity: 0;
transition: opacity 0.5s ease;
}
#tab-1-control:checked~.panels .tab-1 main, #tab-2-control:checked~.panels .tab-2 main, #tab-3-control:checked~.panels .tab-3 main,
#tab-4-control:checked~.panels .tab-4 main, #tab-5-control:checked~.panels .tab-5 main {
max-height: initial;
opacity: 1;
padding: 48px 24px;
}
main h2 {
font-weight: 600;
color: #3a2767;
}
main hr {
border-top: 1px solid #3a2767;
margin: 12px 0;
}
main p {
line-height: 1.5;
text-align: justify;
}
@media all and (min-width: 900px) {
main {
width: 75%;
margin: 0 auto;
}
}
@media all and (max-width: 767px) {
#nav-control:checked~.tabs-list .label-for-tab-1, #nav-control:checked~.tabs-list .label-for-tab-2,
#nav-control:checked~.tabs-list .label-for-tab-3, #nav-control:checked~.tabs-list .label-for-tab-4,
#nav-control:checked~.tabs-list .label-for-tab-5 {
max-height: 46px;
opacity: 1;
}
#open-nav-label {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: block;
cursor: pointer;
}
#nav-control:checked~.tabs-list #open-nav-label {
display: none;
}
#close-nav-label {
display: block;
max-height: 0;
background-color: #000000;
color: #fcf4e7;
text-transform: uppercase;
font-size: 12px;
line-height: 12px;
letter-spacing: 2px;
cursor: pointer;
transition: all 0.25s ease;
overflow-y: hidden;
}
#nav-control:checked~.tabs-list #close-nav-label {
max-height: 36px;
opacity: 1;
padding: 12px 24px;
}
.tabs-list {
position: relative;
}
.tabs-list .panel-label {
padding: 12px 0;
}
.tabs-list .label-for-tab-1, .tabs-list .label-for-tab-2, .tabs-list .label-for-tab-3,
.tabs-list .label-for-tab-4, .tabs-list .label-for-tab-5 {
max-height: 0;
overflow-y: hidden;
transition: all 0.25s ease;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1, #tab-2-control:checked~.tabs-list .label-for-tab-2,
#tab-3-control:checked~.tabs-list .label-for-tab-3, #tab-4-control:checked~.tabs-list .label-for-tab-4,
#tab-5-control:checked~.tabs-list .label-for-tab-5 {
max-height: 46px;
opacity: 1;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1 .panel-label, #tab-2-control:checked~.tabs-list .label-for-tab-2 .panel-label,
#tab-3-control:checked~.tabs-list .label-for-tab-3 .panel-label, #tab-4-control:checked~.tabs-list .label-for-tab-4 .panel-label,
#tab-5-control:checked~.tabs-list .label-for-tab-5 .panel-label {
background-color: #3a2767;
color: #fcf4e7;
}
.panels .container {
width: 100%;
}
}
@media all and (min-width: 768px) {
#tab-1-control:checked~.tabs-list .label-for-tab-1, #tab-2-control:checked~.tabs-list .label-for-tab-2,
#tab-3-control:checked~.tabs-list .label-for-tab-3, #tab-4-control:checked~.tabs-list .label-for-tab-4,
#tab-5-control:checked~.tabs-list .label-for-tab-5 {
transform: translate3d(0, 1px, 0);
border-right: none;
box-shadow: none;
cursor: default;
pointer-events: none;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1.last, #tab-2-control:checked~.tabs-list .label-for-tab-2.last,
#tab-3-control:checked~.tabs-list .label-for-tab-3.last, #tab-4-control:checked~.tabs-list .label-for-tab-4.last,
#tab-5-control:checked~.tabs-list .label-for-tab-5.last {
border-right: 1px solid transparent;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1+li, #tab-2-control:checked~.tabs-list .label-for-tab-2+li,
#tab-3-control:checked~.tabs-list .label-for-tab-3+li, #tab-4-control:checked~.tabs-list .label-for-tab-4+li,
#tab-5-control:checked~.tabs-list .label-for-tab-5+li {
border-left: 1px solid #b0aad3;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1 .panel-label, #tab-2-control:checked~.tabs-list .label-for-tab-2 .panel-label,
#tab-3-control:checked~.tabs-list .label-for-tab-3 .panel-label, #tab-4-control:checked~.tabs-list .label-for-tab-4 .panel-label,
#tab-5-control:checked~.tabs-list .label-for-tab-5 .panel-label {
background-color: #fcf4e7;
color: #3a2767;
}
#tab-1-control:checked~.tabs-list .label-for-tab-1 .panel-label::after,
#tab-2-control:checked~.tabs-list .label-for-tab-2 .panel-label::after,
#tab-3-control:checked~.tabs-list .label-for-tab-3 .panel-label::after,
#tab-4-control:checked~.tabs-list .label-for-tab-4 .panel-label::after,
#tab-5-control:checked~.tabs-list .label-for-tab-5 .panel-label::after {
height: 6px;
}
.tabs-list {
text-align: center;
border-bottom: 1px solid #b0aad3;
}
.tabs-list li {
position: relative;
display: inline-block;
width: 18%;
font-size: 14px;
text-align: center;
border-right: 1px solid #b0aad3;
box-shadow: 0 2px -2px #0000001a;
}
.tabs-list li:hover {
border-right: none;
transition: none;
}
.tabs-list li:hover.last {
border-right: 1px solid transparent;
}
.tabs-list li:hover+li {
border-left: 1px solid #b0aad3;
}
.tabs-list li .panel-label {
position: relative;
padding: 24px 0;
}
.tabs-list li .panel-label::after {
content: "";
position: absolute;
left: 0;
bottom: 100%;
height: 0;
width: 100%;
background-color: #3a2767;
transition: all 0.25s ease;
}
.tabs-list li .panel-label:hover {
padding-top: 25px;
}
.tabs-list li .panel-label:hover::after {
height: 6px;
}
#open-nav-label, #close-nav-label, #nav-control {
display: none;
}
}
Thanks for visiting