← 一覧へ

Accordion / 015 — 上下ボーダー|Top Bottom Border

デザイン見本

  • Simple design with top and bottom borders
  • Clear visual separation
  • Plus/minus icon on the right

上下のボーダーで区切られたデザイン。 リストのような整然とした印象を与え、コンテンツの区切りが明確になります。

実装コード

HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Top Bottom Border Accordion" data-open-text="Close">Top Bottom Border Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>Simple design with top and bottom borders</li>
            <li>Clear visual separation</li>
            <li>Plus/minus icon on the right</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc15-fadeIn {
    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;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    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: 16px;
    font-weight: 300;
    color: #666;
    transition: all 0.3s;
}

.container .btn-box button:hover {
    color: #000;
    border-color: #999;
}

.container .more {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: transparent;
}

.container .more.appear {
    max-height: 200px;
    animation: acc15-fadeIn 0.3s ease;
}

.container:has(.more.appear) .btn-box button::after {
    content: '−';
    color: #000;
}

.container:has(.more.appear) .btn-box button {
    border-bottom: none;
}

.container .more ul {
    list-style: none;
    padding: 12px 0;
    margin: 0;
}

.container .more li {
    padding: 8px 0;
    color: #666;
    font-size: 13px;
}

.container .more li:last-child {
    border-bottom: 1px solid #e0e0e0;
}
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;
                }
            });
        }
    });
});