タブメニュー:ふせん風|Tab Menu: Sticky Note Style

  • Tab 1
  • Tab 2
  • Tab 3

Tab 1 Content

This is the content of Tab 1 in the sticky note style design. It features a yellow sticky note appearance with a friendly and approachable design.

When selected, the tab changes to a yellow sticky note color and displays diagonal line patterns.

Tab 2 Content

This is the content of Tab 2 in the sticky note style design. It’s a simple and user-friendly design.

On hover, it changes to a light yellow color and has a subtle lift effect.

Tab 3 Content

This is the content of Tab 3 in the sticky note style design. It recreates the natural appearance of sticky notes.

Smooth animation effects are applied when switching tabs.

HTML
<div class="container">
    <h1>Sticky Note Style Tab Design</h1>
    
    <div class="tab-container">
        <ul>
            <li class="selected" data-id="tab-1">Tab 1</li>
            <li data-id="tab-2">Tab 2</li>
            <li data-id="tab-3">Tab 3</li>
        </ul>
        <div class="tab-content selected" id="tab-1">
            <p>Tab 1 Content</p>
            <p>This is the content of Tab 1 in the sticky note style design. It features a yellow sticky note appearance with a friendly and approachable design.</p>
            <p>When selected, the tab changes to a yellow sticky note color and displays diagonal line patterns.</p>
        </div>
        <div class="tab-content" id="tab-2">
            <p>Tab 2 Content</p>
            <p>This is the content of Tab 2 in the sticky note style design. It's a simple and user-friendly design.</p>
            <p>On hover, it changes to a light yellow color and has a subtle lift effect.</p>
        </div>
        <div class="tab-content" id="tab-3">
            <p>Tab 3 Content</p>
            <p>This is the content of Tab 3 in the sticky note style design. It recreates the natural appearance of sticky notes.</p>
            <p>Smooth animation effects are applied when switching tabs.</p>
        </div>
    </div>
</div>
CSS
body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

h1 {
    text-align: center;
    padding: 30px;
    background: #f8f8f8;
    color: #333;
    border-bottom: 1px solid #ddd;
}

/* ===== Sticky Note Style Design ===== */
.tab-container {
    overflow: hidden;
    border-radius: 0;
    position: relative;
    background: #f8f8f8;
    padding: 20px;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.tab-container ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    position: relative;
}

.tab-container ul li {
    flex: 1;
    padding: 16px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    color: #666;
    font-weight: 500;
    font-family: 'Arial', sans-serif;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    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;
}

.tab-container ul li::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tab-container ul li.selected {
    color: #333;
    background: #fff9c4;
    border-color: #fbc02d;
    box-shadow: 
        0 4px 12px rgba(251, 192, 45, 0.3),
        0 2px 6px rgba(0, 0, 0, 0.15);
    transform: rotate(0deg) translateY(-4px);
    z-index: 3;
}

.tab-container ul li.selected::before {
    opacity: 1;
    border-bottom-color: #fff9c4;
}

.tab-container ul li.selected::after {
    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;
}

.tab-container ul li:not(.selected):hover {
    background: #fff8e1;
    border-color: #ffb300;
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 
        0 3px 8px rgba(255, 179, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
    padding: 30px;
    min-height: 180px;
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 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;
}

.tab-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;
}

.tab-content.selected {
    display: block;
    animation: stickyNoteIn 0.4s ease;
}

@keyframes stickyNoteIn {
    from { 
        opacity: 0; 
        transform: translateY(-10px) scale(0.95);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
    }
}
JavaScript
const tabContainer = document.querySelector('.tab-container');
const tabMenuItems = tabContainer.querySelectorAll('ul li');
const tabContents = tabContainer.querySelectorAll('.tab-content');

tabMenuItems.forEach(tabMenuItem => {
    tabMenuItem.addEventListener('click', () => {
        tabMenuItems.forEach(item => {
            item.classList.remove('selected');
        });
        
        tabMenuItem.classList.add('selected');
        
        tabContents.forEach(tabContent => {
            tabContent.classList.remove('selected');
        });

        document.getElementById(tabMenuItem.dataset.id).classList.add('selected');
    });
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次