アコーディオン:ボーダー|Accordion: Border

  • ボーダーラインを活用
  • ミニマルで洗練されたデザイン
  • 開閉時のボーダーアニメーション
  • タイポグラフィ重視
  • ビジネス向けの落ち着いたデザイン

HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="ボーダーアコーディオン" data-open-text="閉じる">ボーダーアコーディオン</button>
    </div>
    <div class="more">
        <ul>
            <li>ボーダーラインを活用</li>
            <li>ミニマルで洗練されたデザイン</li>
            <li>開閉時のボーダーアニメーション</li>
            <li>タイポグラフィ重視</li>
            <li>ビジネス向けの落ち着いたデザイン</li>
        </ul>
    </div>
</div>
CSS
@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.container {
  margin-bottom: 30px;
}

.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 || '閉じる';
        } else {
            this.textContent = this.dataset.defaultText;
        }
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次