アコーディオン:カスケード・レフト|Accordion: Cascade Left
- Left to right slide cascade
- Items slide in from left
- Sequential slide animation
- Triangle icons for open/close
- Dynamic slide effect
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Simple Cascade Left Accordion" data-open-text="Close">Simple Cascade Left Accordion</button>
</div>
<div class="more">
<ul>
<li>Left to right slide cascade</li>
<li>Items slide in from left</li>
<li>Sequential slide animation</li>
<li>Triangle icons for open/close</li>
<li>Dynamic slide effect</li>
</ul>
</div>
</div>
CSS
.container {
margin: 20px 0;
position: relative;
}
.btn-box button {
width: 100%;
padding: 15px 0;
background: transparent;
border: none;
font-size: 16px;
font-weight: 400;
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
font-family: 'Arial', sans-serif;
}
.btn-box button::after {
content: '▼';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
font-size: 20px;
font-weight: 300;
color: #666;
transition: all 0.3s ease;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.btn-box button:hover {
color: #000;
}
.btn-box button:hover::after {
color: #000;
}
.more {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: transparent;
}
.more.appear {
max-height: 400px;
}
.container:has(.more.appear) .btn-box button::after {
content: '▲';
transform: translateY(-50%);
color: #000;
}
.more ul {
list-style: none;
padding: 15px 0;
margin: 0;
}
.more li {
padding: 8px 0;
color: #666;
font-size: 14px;
line-height: 1.6;
opacity: 0;
transform: translateX(-30px);
transition: all 0.4s ease;
}
.more.appear li {
opacity: 1;
transform: translateX(0);
}
.more.appear li:nth-child(1) {
transition-delay: 0.1s;
}
.more.appear li:nth-child(2) {
transition-delay: 0.2s;
}
.more.appear li:nth-child(3) {
transition-delay: 0.3s;
}
.more.appear li:nth-child(4) {
transition-delay: 0.4s;
}
.more.appear li:nth-child(5) {
transition-delay: 0.5s;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.btn-box button {
font-size: 14px;
padding: 12px 0;
}
.more ul {
padding: 10px 0;
}
.more.appear {
max-height: 300px;
}
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
const button = document.querySelector('.btn-box button');
const more = document.querySelector('.more');
button.addEventListener('click', function() {
const isOpen = more.classList.contains('appear');
more.classList.toggle('appear');
// Change button text
if (this.dataset.defaultText) {
if (isOpen) {
this.textContent = this.dataset.defaultText;
} else {
this.textContent = this.dataset.openText || 'Close';
}
}
});
});