← 一覧へ

Accordion / 007 — グラスモーフィズム|Glassmorphism

デザイン見本

  • Glass effect background
  • Blur effects for modern look
  • Latest design trend

すりガラスのような質感を再現したグラスモーフィズムデザイン。 背景のぼかし効果(backdrop-filter)と半透明のレイヤーを使用し、奥行きのある美しいUIを実現します。

実装コード

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>Latest design trend</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc7-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(-10px)
    }
    100% {
        opacity: 1;
        transform: none
    }
}

.container {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 15px;
}

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

.container .btn-box button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.container .more {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-top 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);
    margin-top: 0;
    position: relative;
    z-index: 1;
}

.container .more.appear {
    max-height: 200px;
    margin-top: -15px;
    animation: acc7-fadeIn 0.3s ease;
}

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

.container .more li {
    padding: 8px 0;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    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;
                }
            });
        }
    });
});