Accordion / 023 — 左カスケード|Simple Cascade Left
デザイン見本
- Left to right slide cascade
- Items slide in from left
- 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>Dynamic slide effect</li>
</ul>
</div>
</div>
CSS
.container {
width: 100%;
margin-bottom: 0;
}
.container .btn-box button {
width: 100%;
padding: 14px 0;
background: transparent;
border: none;
font-size: 14px;
font-weight: 400;
color: #333;
cursor: pointer;
transition: all 0.3s;
text-align: left;
position: relative;
}
.container .btn-box button::after {
content: '▼';
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
font-size: 18px;
color: #666;
transition: all 0.3s;
}
.container .btn-box button:hover {
color: #000;
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.4s ease;
background: transparent;
}
.container .more.appear {
max-height: 200px;
}
.container:has(.more.appear) .btn-box button::after {
content: '▲';
color: #000;
}
.container .more ul {
list-style: none;
padding: 10px 0;
margin: 0;
}
.container .more li {
padding: 6px 0;
color: #666;
font-size: 13px;
opacity: 0;
transform: translateX(-30px);
transition: all 0.4s ease;
}
.container .more.appear li {
opacity: 1;
transform: translateX(0);
}
.container .more.appear li:nth-child(1) {
transition-delay: 0.1s;
}
.container .more.appear li:nth-child(2) {
transition-delay: 0.2s;
}
.container .more.appear li:nth-child(3) {
transition-delay: 0.3s;
}
JS
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll('.container').forEach(container => {
const button = container.querySelector('.btn-box button');
const content = container.querySelector('.more');
if (button && content) {
button.addEventListener('click', function() {
content.classList.toggle('appear');
// ボタンテキストの切り替え
if (content.classList.contains('appear')) {
this.textContent = this.dataset.openText || 'Close';
} else {
this.textContent = this.dataset.defaultText;
}
});
}
});
});