Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class='MenuButton' onclick="MenuButton()">   <div class='l1'/></div> <div class='l2'></div> <div class='l3'></div> </div> </div>

<div class = 'menu'>
  <div class = 'button1'onclick="Page1()">Page1</div>
  <div class = 'button2'onclick="Page2()">Page2</div>
  <div class = 'button3'onclick="Page3()">Page3</div>
</div>


<div class = 'Page1'></div>
<div class = 'Page2'></div>
<div class = 'Page3'></div>
              
            
!

CSS

              
                .menu{
  z-index:1;
  font-size:30px;
  position:absolute;
  top:100px;
  display: none;
}

.MenuButton{
    position: absolute;
    z-index: 3;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

.l1, .l2, .l3{
    position: relative;
    margin-top: 5px;
    width: 40px;
    height: 3px;
    background: black;
}




.Page1{
  display:none;
  position:absolute;
  background:red;
  width:100%;
  height:100%;
  z-index:2;
  top:0;
  left:0;
}

.Page2{
  display:none;
  position:absolute;
  background:blue;
  width:100%;
  height:100%;
  z-index:2;
  top:0;
  left:0;
}

.Page3{
  display:none;
  position:absolute;
  background:green;
  width:100%;
  height:100%;
  z-index:2;
  top:0;
  left:0;
}


              
            
!

JS

              
                let ActivePage = false //determine which page is open


let tlmenu = gsap.timeline({reversed: true})  //menu button animation
.to('.menu', {display: 'inline'},0)
.to('body', {background: 'yellow'},0)
 .to('.l1', {rotateZ:'45%',y:8},0)
  .to('.l2', {opacity:0},0)
  .to('.l3', {rotateZ:'-45%',y:-8},0);



      let tlMenuPage1 = gsap.timeline({reversed: true})  //first page animation
        .to('.Page1', {display: 'inline'})
        .to('.l1', {width:20,y:15},0)
        .to('.l2', {opacity:1,x:5},0)
        .to('.l3', {width:20,y:-15},0)
      
      let tlMenuPage2 = gsap.timeline({reversed: true}) //second page animation
        .to('.Page2', {display: 'inline'})
        .to('.l1', {width:20,y:15},0)
        .to('.l2', {opacity:1,x:5},0)
        .to('.l3', {width:20,y:-15},0)
      
       let tlMenuPage3 = gsap.timeline({reversed: true}) //third page animation
        .to('.Page3', {display: 'inline'})
        .to('.l1', {width:20,y:15},0)
        .to('.l2', {opacity:1,x:5},0)
        .to('.l3', {width:20,y:-15},0)



function MenuButton() {  //'MenuButton' button
  if(!ActivePage){tlmenu.timeScale(tlmenu.timeScale() < 0 ? 1 : -1.5).resume()} //If no page is open, then the button opens and closes the menu
  
 if(ActivePage==1){tlMenuPage1.timeScale(tlMenuPage1.timeScale() < 0 ? 1 : -1.5).resume();ActivePage=false} //If the first page is open, the button closes it
  
if(ActivePage==2){tlMenuPage2.timeScale(tlMenuPage2.timeScale() < 0 ? 1 : -1.5).resume();ActivePage=false} //If the second page is open, the button closes it
  
if(ActivePage==3){tlMenuPage3.timeScale(tlMenuPage3.timeScale() < 0 ? 1 : -1.5).resume();ActivePage=false} //If a third page is open, the button closes it
}



function Page1(){   //'Page1' button
  ActivePage = 1
  tlMenuPage1.timeScale(tlMenuPage1.timeScale() < 0 ? 1 : -1.5).resume()
}

function Page2(){  //'Page2' button
  ActivePage = 2
  tlMenuPage2.timeScale(tlMenuPage2.timeScale() < 0 ? 1 : -1.5).resume()
}

function Page3(){  //'Page3' button
  ActivePage = 3
  tlMenuPage3.timeScale(tlMenuPage3.timeScale() < 0 ? 1 : -1.5).resume()
}



              
            
!
999px

Console