Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions css-accordion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# CSS-Only Accordion

A fully functional accordion (collapsible sections) built with only HTML and CSS.
No JavaScript required.

## Features
- Expand/collapse multiple sections
- Smooth transitions
- Only one section open at a time (radio button version)
- Responsive design
- Customizable colors and styles
- Accessible (keyboard-friendly)
- Rotating arrow icon for open sections

## How to Use
1. Open `index.html` in any modern browser.
2. Click on section headers to expand or collapse content.

## Folder Structure

css-accordion/
- index.html
- style.css
- README.md
31 changes: 31 additions & 0 deletions css-accordion/idex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS-Only Accordion</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>CSS-Only Accordion</h1>

<div class="accordion">
<input type="radio" name="accordion" id="section1">
<label for="section1">Section 1 <span class="arrow">▼</span></label>
<div class="content">
<p>Content for section 1. Add as much text as you like here.</p>
</div>

<input type="radio" name="accordion" id="section2">
<label for="section2">Section 2 <span class="arrow">▼</span></label>
<div class="content">
<p>Content for section 2.</p>
</div>

<input type="radio" name="accordion" id="section3">
<label for="section3">Section 3 <span class="arrow">▼</span></label>
<div class="content">
<p>Content for section 3.</p>
</div>
</div>
</body>
</html>
53 changes: 53 additions & 0 deletions css-accordion/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body {
font-family: sans-serif;
padding: 2rem;
background: #f0f0f0;
}

.accordion {
max-width: 500px;
margin: auto;
}

.accordion input[type="radio"] {
display: none;
}

.accordion label {
display: flex;
justify-content: space-between;
align-items: center;
background: #3498db;
color: white;
padding: 1rem;
margin-top: 0.5rem;
cursor: pointer;
border-radius: 5px;
transition: background 0.3s;
}

.accordion label:hover {
background: #2980b9;
}

.accordion .content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease, padding 0.3s ease;
background: #ecf0f1;
padding: 0 1rem;
border-radius: 0 0 5px 5px;
}

.accordion input[type="radio"]:checked + label + .content {
max-height: 200px;
padding: 1rem;
}

.arrow {
transition: transform 0.3s;
}

.accordion input[type="radio"]:checked + label .arrow {
transform: rotate(180deg);
}