Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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="menu">
  <ul>
    <li><a href="Home">home</a></li>
    <li><p class="subMenuLinkOne">item 1</p>
      <ul class="subMenu subMenuOne">
        <h2>Sub Menu One</h2>
        <li><a href="sub item 1">sub item 1</a></li>
        <li><a href="sub item 2">sub item 2</a></li>
        <p class="closeOne">Close</p>
      </ul>
    </li>
        <li><p class="subMenuLinkTwo">item 2</p>
      <ul class="subMenu subMenuTwo">
        <h2>Sub Menu Two</h2>
        <li><a href="sub item 1">sub item 1</a></li>
        <li><a href="sub item 2">sub item 2</a></li>
        <p class="closeTwo">Close</p>
      </ul>
    </li>
        <li><p class="subMenuLinkThree">item 3</p>
      <ul class="subMenu subMenuThree">
        <h2>Sub Menu Three</h2>
        <li><a href="sub item 1">sub item 1</a></li>
        <li><a href="sub item 2">sub item 2</a></li>
        <p class="closeThree">Close</p>
      </ul>
    </li>
  </ul>
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body {
  overflow: hidden;
}
.menu {
  padding: 3em;
  position: absolute;
  background: green;
  width: 30%;
  .subMenu {
    display: block;
    position: absolute;
    padding: 3em;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: #000;
    z-index: -99;
    color: white;
    width: 100%;
    margin-left: -100%;
  }
  .subMenuOne {
    background: red;
  }
  .subMenuTwo {
    background: pink;
  }
  .subMenuThree {
    background: purple;
  }
}

li {
  padding: 1em;
}
              
            
!

JS

              
                const tlOne = gsap.timeline();
const tlTwo = gsap.timeline();
const tlThree = gsap.timeline();
  
      const menuOne = document.querySelector('.subMenuLinkOne');
      const menuTwo = document.querySelector('.subMenuLinkTwo');
      const menuThree = document.querySelector('.subMenuLinkThree');
      const exitOne = document.querySelector('.closeOne');
      const exitTwo = document.querySelector('.closeTwo');
      const exitThree = document.querySelector('.closeThree');


//         let currentSection; // when a section is open, store it here.

//         function openMenuSection(section) {
//           let tl = gsap.timeline();
//           if (currentSection) {
//             tl.to('.subMenu', {marginLeft: -"100%"});
//           }
//           tl.to(section, {...open menu animation...});
//           currentSection = section; // record the current section
//           return tl;
//         }
  
  	  	// Sub menu one
        tlOne.reversed(false).progress(0).clear().pause();
        tlOne.fromTo('.subMenuOne', {marginLeft: "-100%"}, {marginLeft: "100%"});
    
        menuOne.addEventListener('click', () => {
          tlOne.play();
        })
   
        exitOne.addEventListener('click', () => {
          tlOne.reverse();
        })
        
        // Sub menu two
        tlTwo.reversed(false).progress(0).clear().pause();
        tlTwo.fromTo('.subMenuTwo', {marginLeft: "-100%"}, {marginLeft: "100%"});
    
        menuTwo.addEventListener('click', () => {
          tlTwo.play();
        })
   
        exitTwo.addEventListener('click', () => {
          tlTwo.reverse();
        })
        
        // Sub menu three
        tlThree.reversed(false).progress(0).clear().pause();
        tlThree.fromTo('.subMenuThree', {marginLeft: "-100%"}, {marginLeft: "100%"});
    
        menuThree.addEventListener('click', () => {
          tlThree.play();
        })
   
        exitThree.addEventListener('click', () => {
          tlThree.reverse();
        })
              
            
!
999px

Console