アコーディオン:シンプルグレー|Accordion: Simple Gray

  • Grayed out simple design
  • No background or borders
  • Clean and minimal appearance
  • Right-aligned dropdown icon
  • Subtle hover effects
HTML
<div class="container">
    <div class="btn-box">
        <button data-default-text="Simple Gray Accordion" data-open-text="Close">Simple Gray Accordion</button>
    </div>
    <div class="more">
        <ul>
            <li>Grayed out simple design</li>
            <li>No background or borders</li>
            <li>Clean and minimal appearance</li>
            <li>Right-aligned dropdown icon</li>
            <li>Subtle hover effects</li>
        </ul>
    </div>
</div>
CSS
@keyframes simpleGrayFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    margin: 20px 0;
    position: relative;
}

.container .btn-box button {
    width: 100%;
    padding: 15px 20px;
    background: #eeeeee;
    border: none;
    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: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #999;
    transition: transform 0.3s ease;
}

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

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

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

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

.container:has(.more.appear) .btn-box button::after {
    transform: translateY(-50%) rotate(180deg);
    color: #666;
}

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

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

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container .btn-box button {
        font-size: 14px;
        padding: 12px 0;
    }
    
    .container .more ul {
        padding: 10px 0;
    }
    
    .container .more.appear {
        max-height: 300px;
    }
}
JavaScript
// Add event listeners to all accordion buttons
document.addEventListener('DOMContentLoaded', function() {
    const accordionButtons = document.querySelectorAll('.btn-box button');
    
    accordionButtons.forEach(button => {
        button.addEventListener('click', function() {
            const container = this.closest('.container');
            const more = container.querySelector('.more');
            const isOpen = more.classList.contains('appear');
                        
            more.classList.toggle('appear');
            
            // Change button text
            if (this.dataset.defaultText) {
                if (isOpen) {
                    this.textContent = this.dataset.defaultText;
                } else {
                    this.textContent = this.dataset.openText || 'Close';
                }
            }
        });
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次