← 一覧へ

Accordion / 004 — ボーダー|Border

デザイン見本

  • Utilizes border lines
  • Minimal and refined design
  • 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>Professional business design</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc4-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(-10px)
    }
    100% {
        opacity: 1;
        transform: none
    }
}

.container {
    width: 100%;
}

.container .btn-box button {
    width: 100%;
    padding: 16px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    font-size: 14px;
    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: 200px;
    animation: acc4-fadeIn 0.3s ease;
}

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

.container .more li {
    padding: 8px 0;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.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;
                }
            });
        }
    });
});