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>Accordions</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="accordion-container">
<h2>Open <strong>Multiple</strong></h2>
<div class="accordions">
<div class="accordions-tab">
<input type="checkbox" id="check1">
<label for="check1" class="accordions-tab-label"><em>Item 1</em></label>
<div class="accordions-tab-content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nulla
amet iste, harum magni earum temporibus veniam enim dolorum illum tempora vero. Et officiis enim
libero illo amet atque cumque! Quam!</div>
</div>
<div class="accordions-tab">
<input type="checkbox" id="check2">
<label for="check2" class="accordions-tab-label"><em>Item 2</em></label>
<div class="accordions-tab-content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Est
iure asperiores voluptate, molestias neque quod facere sapiente vero nostrum atque blanditiis
praesentium impedit repudiandae, repellat dolore eos quos hic temporibus.</div>
</div>
</div>
</div>
<div class="accordion-container">
<h2>Open <strong>Single</strong></h2>
<div class="accordions">
<div class="accordions-tab">
<input type="radio" name="accordion-single" id="radio1">
<label for="radio1" class="accordions-tab-label"><em>Item 1</em></label>
<div class="accordions-tab-content">Lorem ipsum dolor sit amet consectetur adipisicing elit. In
possimus assumenda labore voluptatem eum odio dicta aliquid maiores suscipit officiis ipsam
culpa consequuntur eaque rem, quia officia delectus veritatis similique!</div>
</div>
<div class="accordions-tab">
<input type="radio" name="accordion-single" id="radio2">
<label for="radio2" class="accordions-tab-label"><em>Item 2</em></label>
<div class="accordions-tab-content">Lorem ipsum dolor sit amet consectetur adipisicing elit.
Necessitatibus eveniet aut vero nobis nemo numquam repellat impedit, ipsum a ullam corporis
sapiente voluptate rem veniam excepturi sunt fugiat fugit nostrum.</div>
</div>
<div class="accordions-tab">
<input type="radio" name="accordion-single" id="radio3">
<label for="radio3" class="accordions-tab-close">Close Others ×</label>
</div>
</div>
</div>
</div>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background: #f1bf98;
color: #3f4739;
font-family: serif;
}
h2 {
font-size: 28px;
font-weight: normal;
text-align: center;
letter-spacing: 1px;
margin: 1% 0;
}
input {
position: absolute;
z-index: -1;
opacity: 0;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
width: 80%;
}
.container .accordion-container {
flex: 1;
margin: 1.5% 0;
}
.accordions {
border-radius: 8px;
box-shadow: 0 4px 4px -2px #3f4739bf;
overflow: hidden;
}
.accordions-tab {
width: 100%;
overflow: hidden;
}
.accordions-tab-label {
display: flex;
justify-content: space-between;
background: #c2cfb2;
font-size: 20px;
font-weight: bold;
padding: 15px;
cursor: pointer;
}
.accordions-tab-label:hover, .accordions-tab-close:hover, input:checked+.accordions-tab-label {
background: #86a59c;
}
.accordions-tab-label::after {
content: ">";
height: 15px;
width: 15px;
text-align: center;
transition: all 0.5s ease;
}
.accordions-tab-content {
background: #3f4739;
color: #c2cfb2;
font-size: 16px;
text-align: justify;
max-height: 0;
padding: 0 15px;
transition: all 0.5s ease;
}
.accordions-tab-close {
display: flex;
justify-content: flex-end;
background: #c2cfb2;
font-size: 12px;
padding: 15px;
cursor: pointer;
}
input:checked+.accordions-tab-label::after {
transform: rotate(90deg);
}
input:checked~.accordions-tab-content {
max-height: 100vh;
padding: 15px;
}
Thanks for visiting