← 一覧へ

Accordion / 016 — ホログラム|Holographic

デザイン見本

  • Rainbow holographic effects
  • Iridescent color shifts
  • Eye-catching design

鮮やかなホログラムカラーが変化し続けるインパクトのあるデザイン。 クリック時には他のアコーディオンが自動的に閉じる排他制御ロジックが組み込まれています。

実装コード

HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Holographic Accordion" data-open-text="Close">Holographic Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>Rainbow holographic effects</li>
            <li>Iridescent color shifts</li>
            <li>Eye-catching design</li>
        </ul>
    </div>
</div>
CSS
/* アニメーション定義 */
@keyframes acc16-holographicShift {
    0% {
        background-position: 0% 50%
    }
    50% {
        background-position: 100% 50%
    }
    100% {
        background-position: 0% 50%
    }
}

@keyframes acc16-fadeIn {
    0% {
        opacity: 0;
        transform: translateY(-15px) scale(0.95)
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1)
    }
}

.container {
    margin: 4px 0;
    position: relative;
    width: 100%;
}

.container .btn-box button {
    width: 100%;
    padding: 18px 22px;
    background: linear-gradient(45deg, #ff0080, #ff8c00, #40e0d0, #ee82ee, #ff0080, #ff8c00, #40e0d0, #ee82ee);
    background-size: 400% 400%;
    border: none;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: all 0.4s ease;
    text-align: left;
    position: relative;
    animation: acc16-holographicShift 3s ease infinite;
    overflow: hidden;
}

.container .btn-box button:hover {
    transform: translateY(-3px) scale(1.02);
}

.container .more {
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
    background: linear-gradient(135deg, rgba(255, 0, 150, 0.1), rgba(0, 255, 255, 0.1), rgba(255, 255, 0, 0.1));
    border-radius: 0 0 15px 15px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-top: 0;
    z-index: 1;
    position: relative;
}

.container .more.appear {
    max-height: 200px;
    margin-top: -5px;
    animation: acc16-fadeIn 0.6s ease;
}

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

.container .more li {
    padding: 10px 0;
    color: #333;
    font-weight: 500;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
}

.container .more li:last-child {
    border-bottom: none;
}
JS
document.addEventListener("DOMContentLoaded", () => {
    const containers = document.querySelectorAll('.container');
    
    containers.forEach(container => {
        const button = container.querySelector('.btn-box button');
        const content = container.querySelector('.more');
        
        if (button && content) {
            button.addEventListener('click', function() {
                const isOpen = content.classList.contains('appear');
                
                // 他のアコーディオンを閉じる
                containers.forEach(c => {
                    const cContent = c.querySelector('.more');
                    const cButton = c.querySelector('.btn-box button');
                    if(cContent) cContent.classList.remove('appear');
                    if(cButton) cButton.textContent = cButton.dataset.defaultText;
                });
                
                // クリックされたものだけ開く
                if (!isOpen) {
                    content.classList.add('appear');
                    this.textContent = this.dataset.openText || 'Close';
                }
            });
        }
    });
});