Accordion with Check Boxes & Radio Buttons
Accordion with Check Boxes & Radio Buttons

Accordion with Check Boxes & Radio Buttons
Accordion with Check Boxes & Radio Buttons
You can be use Accordion with Check Boxes & Radio Buttons to animate a data list with icons, contents with 3+ items, etc. and create user attractive UI components.
So if you are a person who wishes to develop a website, you have to know how to create 3D animations properly. Check out our tutorial and you can learn this techniques and use it on your web development. Below sections shows how to develop this animations.
How to create? We are here to solve your problem. In this article we discuss how to create a hover effect animations. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag as below.
<body>
<section class="accordion">
<div class="tab">
<input type="checkbox" name="accordion-1" id="cb1" checked>
<label for="cb1" class="tab__label">Checkbox</label>
<div class="tab__content">
<p>Pure CSS accordion based on the "input:checked + label" style trick.</p>
</div>
</div>
<div class="tab">
<input type="checkbox" name="accordion-1" id="cb2">
<label for="cb2" class="tab__label">Open multiple</label>
<div class="tab__content">
<p>Using <code><input type="checkbox"></code> allows to have several tabs open at the same time.</p>
</div>
</div>
</section>
<section class="accordion accordion--radio">
<div class="tab">
<input type="radio" name="accordion-2" id="rd1">
<label for="rd1" class="tab__label">Radio</label>
<div class="tab__content">
<p>If you want to have only one tab open, you can use <code><input type="checkbox"></code>.</p>
</div>
</div>
<div class="tab">
<input type="radio" name="accordion-2" id="rd2">
<label for="rd2" class="tab__label">Open single</label>
<div class="tab__content">
<p>But if you wanna close the opened tab, you must add a "close" button somewhere, like the one below, that is just another styled radio input.</p>
</div>
</div>
<div class="tab">
<input type="radio" name="accordion-2" id="rd3">
<label for="rd3" class="tab__close">Close open tab ×</label>
</div>
</section>
</body>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag as below.
<style>
:root {
--primary: #2a1e65;
--secondary: #5e8b08;
--background: #ffd2d2;
--highlight: #ffda79;
/* Theme color */
--theme: var(--primary);
}
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
display: grid;
place-content: center;
grid-template-columns: repeat(auto-fit, min(100%, 30rem));
min-height: 100vh;
place-items: start;
gap: 1rem;
margin: 0;
padding: 1rem;
color: var(--primary);
background: var(--background);
}
/* Core styles/functionality */
.tab input {
position: absolute;
opacity: 0;
z-index: -1;
}
.tab__content {
max-height: 0;
overflow: hidden;
transition: all 0.35s;
}
.tab input:checked~.tab__content {
max-height: 10rem;
}
/* Visual styles */
.accordion {
color: var(--theme);
border: 2px solid;
border-radius: 0.5rem;
overflow: hidden;
}
.tab__label,
.tab__close {
display: flex;
color: white;
background: var(--theme);
cursor: pointer;
}
.tab__label {
justify-content: space-between;
padding: 1rem;
}
.tab__label::after {
content: "\276F";
width: 1em;
height: 1em;
text-align: center;
transform: rotate(90deg);
transition: all 0.35s;
}
.tab input:checked+.tab__label::after {
transform: rotate(270deg);
}
.tab__content p {
margin: 0;
padding: 1rem;
}
.tab__close {
justify-content: flex-end;
padding: 0.5rem 1rem;
font-size: 0.75rem;
}
.accordion--radio {
--theme: var(--secondary);
}
/* Arrow animation */
.tab input:not(:checked)+.tab__label:hover::after {
animation: bounce 0.5s infinite;
}
@keyframes bounce {
25% {
transform: rotate(90deg) translate(0.25rem);
}
75% {
transform: rotate(90deg) translate(-0.25rem);
}
}
</style>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.
Out Put


Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.