<!DOCTYPE html>
<html lang="es">
<head>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta charset="UTF-8">
	<title>Css slide toggle</title>
	<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
</head>
<body>
	
<div class="menu">
    <input type="checkbox" id="check">
    <label for="check" class="button">
        <span></span>
        <span></span>
        <span></span>
    </label>
    <nav>
        <a href="#">Element 1</a>
        <a href="#">Element 2</a>
        <a href="#">Element 3</a>
    </nav>
</div>	


<div class="content">
    <h1>Section 1</h1>
</div>
<div class="content sec2">
    <h1>Section 2</h1>
</div>

</body>
</html>
* {
	margin:0 ;
	padding: 0;
	box-sizing: border-box;
   font-family: 'Poppins';
}

/* content */
.content{
    width: 100%;
    height: 100vh;
    background: url(https://images.unsplash.com/photo-1551334787-21e6bd3ab135?ixlib=rb-1.2.1&auto=format&fit=crop&w=1502&q=80);
    background-position: center;
    background-size: cover;
    color: white;
    text-align: center;
    position: relative;
}
.sec2{
    background: url(https://images.unsplash.com/photo-1551309292-e185c0b6e22a?ixlib=rb-1.2.1&auto=format&fit=crop&w=1500&q=80);
    background-position: center;
    background-size: cover;
}
h1{
    font-size: 50px;
    position: absolute;
    width: 100%;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
}


.menu{
    text-align: right;
    position: fixed;
    width: 100%;
    z-index: 200;
}
/* I hide the checkbox because I only need the label */
#check{
    display: none;
}

.button{
    width: 48px;
    height: 48px;
    background: rgb(255, 196, 0);
    padding: 12px;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s ease-in;
    padding-top: 8px;
    line-height: 8px;
    text-align: left;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 201;
}
.button:hover{
    background: #ff9d00;
}
.button span{
    height: 3px;
    width: 100%;
    background: white;
    display: inline-block;
    transition: all 0.5s cubic-bezier(.62,.43,.35,1.47);
}


/* toggle icon animation */
#check:checked ~ .button span:nth-child(1){
    width: 100%;
    transform: rotate(45deg) translateY(6px) translateX(6px);
}
#check:checked ~ .button span:nth-child(2){
    width: 0;
}

#check:checked ~ .button span:nth-child(3){
    width: 100%;
    transform: rotate(-45deg) translateY(-7px) translateX(7px);
}


/* the nav height is set to 0 when the navbar is closed */

nav{
    text-align: left;
    overflow: hidden;
    transition: all 0.4s ease;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: #ffffff;
    height: 0;
}
nav a{
    text-decoration: none;
    color: #0c1019;
    display: block;
    font-size: 18px;
    transition: all 0.4s cubic-bezier(.22,.43,.35,1.5);
    opacity: 0;
    transform: scale(0);
    transform-origin: top;
    text-align: center;
    border-bottom: 1px solid #b4ac97;
}

nav a:hover{
    background: #ffdd7f;
}

/* the nav height will be set to the height in pixels that would have for default, using height:auto won't work but you can put that value in pixels creating the slide*/
#check:checked ~ nav{
    height: 144px;
}

#check:checked ~ nav a{
    padding: 10px;
    opacity: 1;
    transform: scale(1);
}

/* you can edit the direction where the slide starts, changing the height animation to width, but it will take some changes.
for example:

nav{
    width: 0%;
    background: #ffffff;
    height: auto;
    max-height 144px;
    opacity: 0;
}

#check:checked ~ nav{
    width: 100%;
    opacity: 1;
} 

*/

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.