アコーディオン:シンプルラインズ|Accordion: Simple Lines

  • Simple design with top and bottom borders
  • Clean and organized appearance
  • Plus/minus icon on the right
  • Perfect for structured layouts
  • Clear visual separation
HTML
<div class="container">
  <div class="btn-box">
      <button data-default-text="Top Bottom Border Simple Accordion" data-open-text="Close">Top Bottom Border Simple Accordion</button>
  </div>
  <div class="more">
      <ul>
          <li>Simple design with top and bottom borders</li>
          <li>Clean and organized appearance</li>
          <li>Plus/minus icon on the right</li>
          <li>Perfect for structured layouts</li>
          <li>Clear visual separation</li>
      </ul>
  </div>
</div>
CSS
@keyframes borderFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  margin: 20px 0;
  position: relative;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.container .btn-box button {
  width: 100%;
  padding: 20px 0;
  background: transparent;
  border: none;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  font-size: 16px;
  font-weight: 400;
  color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  position: relative;
  font-family: 'Arial', sans-serif;
}

.container .btn-box button::after {
  content: '+';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  font-weight: 300;
  color: #666;
  transition: all 0.3s ease;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

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

.container .more.appear {
  max-height: 400px;
  animation: borderFadeIn 0.3s ease;
}

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

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

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

.container .more li {
  padding: 10px 0;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.container .more li:last-child {
  border-bottom: 1px solid #e0e0e0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .container .btn-box button {
    font-size: 14px;
    padding: 15px 0;
  }
  
  .container .more ul {
    padding: 15px 0;
  }
  
  .container .more.appear {
    max-height: 300px;
  }
}
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;
        }
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次