アコーディオン:グレーアウト|Accordion: Gray Out

  • Muted gray color scheme
  • Subtle transparency effects
  • Elegant fade animations
  • Professional and calm
  • Minimal visual impact
HTML
<div class="container">
    <div class="accordion-container">
        <div class="btn-box">
            <button data-default-text="Grayed Out Accordion" data-open-text="Close">Grayed Out Accordion</button>
        </div>
        <div class="content">
            <ul>
                <li>Muted gray color scheme</li>
                <li>Subtle transparency effects</li>
                <li>Elegant fade animations</li>
                <li>Professional and calm</li>
                <li>Minimal visual impact</li>
            </ul>
        </div>
    </div>
</div>
CSS
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8f9fa;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
}

/* ===== Grayed Out Accordion ===== */
@keyframes grayFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-8px);
        filter: grayscale(100%);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: grayscale(0%);
    }
}

.accordion-container {
    margin: 20px;
    position: relative;
}

.btn-box button {
    width: 100%;
    padding: 18px 25px;
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid rgba(128, 128, 128, 0.3);
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.4s ease;
    text-align: left;
    position: relative;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.btn-box button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.1) 0%, 
        rgba(255, 255, 255, 0.05) 50%, 
        rgba(255, 255, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-box button::after {
    content: '▼';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
    color: #999;
    font-size: 12px;
    opacity: 0.7;
}

.btn-box button:hover {
    background: rgba(128, 128, 128, 0.15);
    border-color: rgba(128, 128, 128, 0.5);
    color: #555;
}

.btn-box button:hover::before {
    opacity: 1;
}

.btn-box button:hover::after {
    color: #777;
    opacity: 1;
}

.content {
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease;
    background: rgba(128, 128, 128, 0.05);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-top: none;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    margin-top: -1px;
}

.content.appear {
    max-height: 500px;
    animation: grayFadeIn 0.4s ease;
}

.accordion-container:has(.content.appear) .btn-box button {
    background: rgba(128, 128, 128, 0.2);
    border-color: rgba(128, 128, 128, 0.6);
    color: #444;
}

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

.content ul {
    list-style: none;
    padding: 25px;
    margin: 0;
}

.content li {
    padding: 12px 0;
    color: #777;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    font-size: 15px;
    line-height: 1.6;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.content li:hover {
    color: #555;
    opacity: 1;
    padding-left: 5px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .btn-box button {
        font-size: 14px;
        padding: 15px 20px;
    }
    
    .content ul {
        padding: 20px;
    }
    
    .content.appear {
        max-height: 400px;
    }
}
JavaScript
const accordionContainer = document.querySelector('.accordion-container');
const button = accordionContainer.querySelector('button');
const content = accordionContainer.querySelector('.content');
const defaultText = button.getAttribute('data-default-text');
const openText = button.getAttribute('data-open-text');

button.addEventListener('click', () => {
    const isOpen = content.classList.contains('appear');

    if (isOpen) {
        content.classList.remove('appear');
        button.textContent = defaultText;
    } else {
        content.classList.add('appear');
        button.textContent = openText;
    }
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次