218
15 Best CSS Accordion Designs You’ve Never 👀 Seen Before
Hello Friends, I have listed over 15 best css accordion designs made with HTML, CSS, and JS. Check out these excellent accordion examples which are available on Codepen.
In this step, we need to create a new project folder and files(index.html, style.css) for creating a simple accordion design. In the next step, you will start creating the structure of the webpage.
In this step, we will add the HTML code to create the basic structure of the project.
<!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>How to create accordion with css only</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@200;400&display=swap" rel="stylesheet">
</head>
<body>
</body>
</html>
This is the base structure of most web pages that use HTML.
Add the following code inside the <body>
tag:
<div class="accordion_outer">
<div class="container">
<details>
<summary>Section 1</summary>
<div class="details">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</details>
<details>
<summary>Section 2</summary>
<div class="details">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</details>
<details>
<summary>Section 3</summary>
<div class="details">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</details>
<details>
<summary>Section 4</summary>
<div class="details">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</details>
</div>
</div>
In this step, we will add styles to the section class Inside style.css file
* {
padding: 0;
margin: 0;
font-family: 'IBM Plex Sans', sans-serif;
}
html,body {
background: #dae9f9;
}
.container {
width: 95%;
max-width: 1140px;
margin: auto;
}
.accordion_outer {
padding: 50px 0;
}
details {
background: #f2f4f6;
padding: 10px;
font-size: 18px;
margin-bottom: 10px;
cursor: pointer;
}
.details {
background: #fff;
padding: 10px;
margin-top: 10px;
cursor: auto;
}
In this collection, I have listed over 10+ best accordion designs made with HTML, CSS and JavaScript. Check out these awesome CSS accordion examples which are available on Codepen.
218