アコーディオン:ふせん風|Accordion: Sticky Note Style

  • Yellow sticky note appearance
  • Natural paper texture
  • Diagonal line patterns
  • Friendly and approachable
  • Handwritten feel
HTML
<div class="container">
    <div class="accordion-container">
        <div class="btn-box">
            <button data-default-text="Sticky Note Style Accordion" data-open-text="Close">Sticky Note Style Accordion</button>
        </div>
        <div class="content">
            <ul>
                <li>Yellow sticky note appearance</li>
                <li>Natural paper texture</li>
                <li>Diagonal line patterns</li>
                <li>Friendly and approachable</li>
                <li>Handwritten feel</li>
            </ul>
        </div>
    </div>
</div>
CSS
body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    line-height: 1.6;
}

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

/* ===== Sticky Note Style Accordion ===== */
@keyframes stickyNoteIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.btn-box button {
    width: 100%;
    padding: 20px 25px;
    background: #fff9c4;
    border: 1px solid #fbc02d;
    border-radius: 8px 8px 0 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    font-family: 'Arial', sans-serif;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.08);
    transform: rotate(0deg);
    transform-origin: bottom center;
}

.btn-box button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(251, 192, 45, 0.1) 2px,
            rgba(251, 192, 45, 0.1) 4px
        );
    border-radius: 8px 8px 0 0;
    pointer-events: none;
}

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

.btn-box button:hover {
    background: #fff8e1;
    border-color: #ffb300;
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 
        0 4px 8px rgba(255, 179, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    margin-top: 10px;
}

.content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #fff9c4, #fbc02d, #fff9c4);
    border-radius: 8px 8px 0 0;
}

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

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

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

.content li {
    padding: 12px 0;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    padding-left: 20px;
}

.content li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #fbc02d;
    font-weight: bold;
    font-size: 18px;
}

.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をコピーしました!
目次