アコーディオン:ボーダー|Accordion: Border
- Utilizes border lines
- Minimal and refined design
- Border animation on open/close
- Typography-focused
- Professional business design
HTML
<div class="container">
<div class="btn-box">
<button data-default-text="Border Accordion" data-open-text="Close">Border Accordion</button>
</div>
<div class="more">
<ul>
<li>Utilizes border lines</li>
<li>Minimal and refined design</li>
<li>Border animation on open/close</li>
<li>Typography-focused</li>
<li>Professional business design</li>
</ul>
</div>
</div>
CSS
@keyframes fadeIn {
0% {
opacity: 0;
transform: translateY(-10px);
}
100% {
opacity: 1;
transform: none;
}
}
.container {
margin-bottom: 30px;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.container .btn-box button {
width: 100%;
padding: 20px 25px;
background: transparent;
border: none;
border-bottom: 2px solid #e0e0e0;
font-size: 16px;
font-weight: 600;
color: #333;
cursor: pointer;
transition: all 0.3s ease;
text-align: left;
position: relative;
}
.container .btn-box button::after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 0;
height: 2px;
background: #2196f3;
transition: width 0.3s ease;
}
.container .btn-box button:hover::after {
width: 100%;
}
.container .more {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
background: #fff;
border-bottom: 2px solid #e0e0e0;
}
.container .more.appear {
max-height: 300px;
animation: fadeIn 0.3s ease;
}
.container .more ul {
list-style: none;
padding: 20px 0;
margin: 0;
}
.container .more li {
padding: 12px 0;
color: #666;
border-bottom: 1px solid #f0f0f0;
font-weight: 400;
line-height: 1.6;
}
.container .more li:last-child {
border-bottom: none;
}
/* レスポンシブ対応 */
@media (max-width: 768px) {
.container .btn-box button {
font-size: 14px;
padding: 15px 20px;
}
.container .more ul {
padding: 15px 0;
}
}
JavaScript
document.addEventListener('DOMContentLoaded', function() {
const button = document.querySelector('.btn-box button');
const content = document.querySelector('.more');
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;
}
});
});