アコーディオン:ガラスモーフィズム|Accordion: Glassmorphism

  • Glass effect background
  • Blur effects for modern look
  • Semi-transparent elegant design
  • Beautiful harmony with background
  • Latest design trend
HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Glassmorphism Accordion" data-open-text="Close">Glassmorphism Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>Glass effect background</li>
            <li>Blur effects for modern look</li>
            <li>Semi-transparent elegant design</li>
            <li>Beautiful harmony with background</li>
            <li>Latest design trend</li>
        </ul>
    </div>
</div>
CSS
@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  margin: 0;
  padding: 20px;
  font-family: Arial, sans-serif;
}

.container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  border-radius: 15px;
  margin-left: auto;
  margin-right: auto;
  max-width: 600px;
}

.container .btn-box button {
  width: 100%;
  padding: 20px 25px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
}

.container .btn-box button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(31, 38, 135, 0.5);
}

.container .more {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  border-radius: 0 0 15px 15px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
  margin-top: -15px;
  position: relative;
  z-index: 1;
}

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

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

.container .more li {
  padding: 12px 0;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 400;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

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

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .container {
    margin: 0 10px 20px;
  }
  
  .container .btn-box button {
    font-size: 14px;
    padding: 15px 20px;
  }
  
  .container .more ul {
    padding: 15px;
  }
}
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をコピーしました!
目次