ハンバーガーメニュー:パステルカラー|Hamburger Menu: pastel colors

HTML
<div class="container">
    <div class="hamburger-menu">
        <div class="line"></div>
        <div class="line"></div>
        <div class="line"></div>
    </div>
    <nav class="nav-menu">
        <a href="#">メニュー1</a>
        <a href="#">メニュー2</a>
        <a href="#">メニュー3</a>
    </nav>
</div>
CSS
@keyframes fadeIn {
    0% {
        top: 45%;
        opacity: 0;
    }
    
    100% {
        top: 50%;
        opacity: 1;
    }
}

.container {
    position: relative;
    width: 100%;
    height: 300px;
    background: #f8f9fa;
    border-radius: 25px;
    margin: 20px 0;
}

.hamburger-menu {
    width: 40px;
    height: 30px;
    position: absolute;
    top: 20px;
    right: 20px;
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 10px;
    box-shadow: 
        0 8px 32px rgba(0,0,0,0.1),
        0 4px 16px rgba(0,0,0,0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
}

.hamburger-menu:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 
        0 12px 40px rgba(0,0,0,0.15),
        0 6px 20px rgba(0,0,0,0.1);
}

.line {
    background: linear-gradient(90deg, #fd79a8, #a29bfe);
    height: 3px;
    width: calc(100% - 20px);
    position: absolute;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-radius: 3px;
    left: 10px;
    box-shadow: 0 2px 8px rgba(253, 121, 168, 0.3);
}

.line:nth-of-type(1) {
    top: 25%;
}

.line:nth-of-type(2) {
    top: 50%;
    transform: translateY(-50%);
}

.line:nth-of-type(3) {
    bottom: 25%;
}

.hamburger-menu.active > .line:nth-of-type(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    background: linear-gradient(90deg, #ff7675, #fd79a8);
    box-shadow: 0 3px 12px rgba(255, 118, 117, 0.4);
}

.hamburger-menu.active > .line:nth-of-type(2) {
    opacity: 0;
    transform: translateX(-30px) scale(0.5);
}

.hamburger-menu.active > .line:nth-of-type(3) {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
    background: linear-gradient(90deg, #a29bfe, #74b9ff);
    box-shadow: 0 3px 12px rgba(162, 155, 254, 0.4);
}

.nav-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    justify-content: center;
    padding: 25px;
    width: 50%;
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 25%, #fd79a8 50%, #a29bfe 75%, #74b9ff 100%);
    border-radius: 30px;
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.1),
        0 10px 20px rgba(0,0,0,0.05);
    opacity: 0;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.3);
}

.nav-menu.active {
    display: flex;
    animation: fadeIn 0.7s forwards;
}

.nav-menu a {
    text-decoration: none;
    color: white;
    padding: 12px 20px;
    margin: 8px;
    border-radius: 25px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-weight: 500;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.nav-menu a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.nav-menu a:hover::before {
    left: 100%;
}
JavaScript
const hamburgerMenu = document.querySelector('.hamburger-menu');
const navMenu = document.querySelector('.nav-menu');

hamburgerMenu.addEventListener('click', function() {
    hamburgerMenu.classList.toggle('active');
    navMenu.classList.toggle('active');
});
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次