<div class="accordion-container">
<details class="accordion-item">
<summary class="accordion-title">Section 1 Title</summary>
<div class="accordion-content">
<p>Content for section 1. This area expands when the title is clicked, revealing more information.</p>
</div>
</details>
<details class="accordion-item">
<summary class="accordion-title">Section 2 Title</summary>
<div class="accordion-content">
<p>Content for section 2. You can put any HTML content here, such as text, images, or lists.</p>
</div>
</details>
</div>body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f4f4f4;
}
.accordion-container {
max-width: 600px;
margin: 20px auto;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
overflow: hidden; /* Ensures border-radius clips children */
}
.accordion-item {
border-bottom: 1px solid #e0e0e0;
}
.accordion-item:last-child {
border-bottom: none;
}
.accordion-title {
padding: 15px 20px;
font-weight: bold;
cursor: pointer;
outline: none; /* Remove default focus outline */
display: flex;
justify-content: space-between;
align-items: center;
transition: background-color 0.2s ease;
color: #333;
}
.accordion-title:hover {
background-color: #f9f9f9;
}
.accordion-title::after {
content: '\002B'; /* Plus sign */
font-size: 1.2em;
transition: transform 0.3s ease;
}
.accordion-item[open] > .accordion-title {
background-color: #e9e9e9;
}
.accordion-item[open] > .accordion-title::after {
content: '\2212'; /* Minus sign */
transform: rotate(180deg);
}
.accordion-content {
padding: 15px 20px;
background-color: #fff;
line-height: 1.6;
color: #555;
border-top: 1px dashed #e0e0e0;
}
/* For smoother animation (optional) */
.accordion-item[open] .accordion-content {
animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.