This website is the best viewed in bigger devices.

How To Design - Curtain Menu


Learn how to create a Curtain Layer Responsive Menu with HTML, CSS and JavaScript.


basic form

How To Create a Curtain Layer Responsive Menu

Step 1) Add HTML

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Curtain Menu</title>
    <link rel="icon" href="images/favicon.png" type="image/png" sizes="16x16">
    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,400i,600,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
</head>

<body>
    <div id="curtain">
        <span></span>
        <span></span>
        <span></span>
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Services</a></li>
            <li><a href="#">Portfolio</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
        <div class="toggle" onclick="toggle()"></div>
    </div>

    <h1>How To Create A Cool <br> Curtain Layer Responsive Menu</h1>
    
</body>

</html>

Step 2) Add CSS:

/*

This is a Curtain Layer Responsive Menu using HTML and CSS and JavaScript. You can freely use it in your project.
It is made with ♥ by Learn Computer Academy. Visit our website: www.learncomputer.in

*/


/* Normalization */

*,
*::before,
*::after {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    color: #000;
    line-height: 1.3;
    background-color: #fff;
    padding: 0;
    margin: 0;
}

a {
    text-decoration: none;
    display: inline-block;
}

    h1{ font-size: 4em; }
    
    /* Curtain Layers CSS */

    #curtain{
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #curtain span{
        position: absolute;
        top: 0;
        left: 0;
        width: 200%;
        height: 100%;
        display: block;
        transform-origin: bottom left;
        transition: 0.5s ease-in-out;
        transform: rotate(-90deg);
    }

    #curtain span:nth-child(1){
        background-color: #ff1f6b;
        transform: rotate(-90deg);
        transition-delay: 0.2s;
    }

    #curtain span:nth-child(2){
        background-color: #219dff;
        transform: rotate(-90deg);
        transition-delay: 0.1s;
    }

    #curtain span:nth-child(3){
        background-color: #111;
        transform: rotate(-90deg);
        transition-delay: 0s;
    }

    /* .active Class CSS */

    #curtain.active span{
        transform: rotate(0deg);            
    }

    #curtain.active span:nth-child(1){
        z-index: 1;
        transition-delay: 0s; 
    }

    #curtain.active span:nth-child(2){
        z-index: 2;
        transition-delay: 0.1s; 
    } 

    #curtain.active span:nth-child(3){
        z-index: 3;
        transition-delay: 0.2s; 
    }

    /* Menu Icon CSS*/

    .toggle{
        position: fixed;
        top: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: #fff url(open.png);
        background-size: 30px;
        background-repeat: no-repeat;
        background-position: center;
        z-index: 1000;
        cursor: pointer;
        transition: 0.5s;
        box-shadow: 0px 0px 25px 0px rgba(0,0,0,.3);
    }

    #curtain.active .toggle{
        background:#fff url(close.png);
        background-size: 25px;
        background-repeat: no-repeat;
        background-position: center; 
        box-shadow: 0px 0px 25px 0px rgba(255,255,255,.3); 
    }
    
    /* Menu Items CSS */

    #curtain ul{
        visibility: hidden;
        opacity: 0;
        transition: 0.7s;
        text-align: center;
        z-index: 99999;
    }

    #curtain.active ul{
        visibility: visible;
        opacity: 1;
        transition-delay: 0.7s;

    }

    #curtain ul li{
        list-style: none;
        margin: 10px 0;
    }

    #curtain ul li a{
        text-decoration: none;
        color: #fff;
        font-size: 4em;
        transition: color .5s ease-in-out;
    }

    #curtain ul li a:hover{
        color: #ff1f6b;
        font-size: 4em;
    }


Step 3) Add JavaScript:

<script>
    //To add and remove .active class in #curtain div

    function toggle(){
        var curtain = document.getElementById('curtain');
        curtain.classList.toggle('active');
    }
</script>