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

  • Single line with centered text design
  • Minimal and clean appearance
  • Centered text with decorative lines
  • Simple and elegant
  • Perfect for minimal layouts
HTML
<div class="container">
  <div class="btn-box">
      <button data-default-text="Single Line Accordion" data-open-text="Close">Single Line Accordion</button>
  </div>
  <div class="more">
      <ul>
          <li>Single line with centered text design</li>
          <li>Minimal and clean appearance</li>
          <li>Centered text with decorative lines</li>
          <li>Simple and elegant</li>
          <li>Perfect for minimal layouts</li>
      </ul>
  </div>
</div>
CSS
@keyframes lineFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  margin: 30px 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;
  font-size: 16px;
  font-weight: 400;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  font-family: 'Arial', sans-serif;
  letter-spacing: 2px;
}

.container .btn-box button::before,
.container .btn-box button::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: #ddd;
  transition: all 0.3s ease;
}

.container .btn-box button::before {
  left: 0;
}

.container .btn-box button::after {
  right: 0;
}

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

.container .btn-box button:hover::before,
.container .btn-box button:hover::after {
  background: #999;
  width: 32%;
}

.container .more {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
  background: transparent;
  text-align: center;
}

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

.container .more ul {
  list-style: none;
  padding: 20px 0;
  margin: 0;
  text-align: left;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.container .more li {
  padding: 10px 0;
  color: #666;
  font-size: 14px;
  line-height: 1.6;
  border-bottom: 1px solid #f0f0f0;
  text-align: center;
}

.container .more li:last-child {
  border-bottom: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .container .btn-box button {
    font-size: 14px;
    padding: 15px 0;
    letter-spacing: 1px;
  }
  
  .container .btn-box button::before,
  .container .btn-box button::after {
    width: 25%;
  }
  
  .container .btn-box button:hover::before,
  .container .btn-box button:hover::after {
    width: 30%;
  }
  
  .container .more ul {
    padding: 15px 20px;
    text-align: left;
  }
  
  .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をコピーしました!
目次