Accordion / 013 — 中央ライン|Single Line Centered
デザイン見本
- Single line with centered text
- Minimal and clean appearance
- Perfect for minimal layouts
中央揃えのテキストと左右のラインで構成されたシンプルなデザイン。 ミニマルなレイアウトに溶け込み、洗練された雰囲気を作り出します。
実装コード
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Single Line Accordion" data-open-text="Close">Single Line Accordion</button>
</div>
<div class="more">
<ul>
<li>Single line with centered text</li>
<li>Minimal and clean appearance</li>
<li>Perfect for minimal layouts</li>
</ul>
</div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc13-lineFadeIn {
0% {
opacity: 0;
transform: translateY(-8px)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
.container {
width: 100%;
}
.container .btn-box button {
width: 100%;
padding: 16px 0;
background: transparent;
border: none;
font-size: 14px;
font-weight: 400;
color: #666;
cursor: pointer;
transition: all 0.3s ease;
text-align: center;
position: relative;
letter-spacing: 2px;
}
.container .btn-box button::before,
.container .btn-box button::after {
content: '';
position: absolute;
top: 50%;
width: 28%;
height: 1px;
background: #ddd;
transition: all 0.3s;
}
.container .btn-box button::before {
left: 0;
}
.container .btn-box button::after {
right: 0;
}
.container .btn-box button:hover {
color: #333;
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease;
background: transparent;
}
.container .more.appear {
max-height: 200px;
animation: acc13-lineFadeIn 0.3s ease;
}
.container .more ul {
list-style: none;
padding: 12px 0;
margin: 0;
}
.container .more li {
padding: 8px 0;
color: #666;
font-size: 13px;
border-bottom: 1px solid #f0f0f0;
text-align: center;
}
.container .more li:last-child {
border-bottom: none;
}
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;
}
});
}
});
});