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 id="sidemenu" class="sidemenu">

  <div id="sideMenuItem0" class="chapterMod">
    <div id="IDS_navItemLabel1" class="moduleBtn">
      <a href="#">ONE</a>
    </div>
    <div id="IDS_Section0Chapter0" class="boxBtn">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in metus non felis semper egestas. Donec pharetra erat nisi, vel maximus ex rhoncus vel. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam sit amet aliquet nunc. Quisque cursus sem a varius sollicitudin. Aenean a vulputate enim. Proin pharetra, tortor id semper imperdiet, metus turpis laoreet velit, ut vehicula orci magna sed massa. Phasellus tincidunt lectus mattis pellentesque porttitor. Donec at mauris sit amet leo pellentesque eleifend. Nullam at elit iaculis, hendrerit dui ac, porta eros. Etiam tempor vehicula rutrum. Vivamus cursus leo eu nulla vehicula hendrerit.
    </div>
  </div>

  <div id="sideMenuItem1" class="chapterMod">
    <div id="IDS_navItemLabel2" class="moduleBtn">
      <a href="#">TWO</a>
    </div>
    <div id="IDS_Section1Chapter1" class="boxBtn">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in metus non felis semper egestas. Donec pharetra erat nisi, vel maximus ex rhoncus vel. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam sit amet aliquet nunc. Quisque cursus sem a varius sollicitudin. Aenean a vulputate enim. Proin pharetra, tortor id semper imperdiet, metus turpis laoreet velit, ut vehicula orci magna sed massa. Phasellus tincidunt lectus mattis pellentesque porttitor. Donec at mauris sit amet leo pellentesque eleifend. Nullam at elit iaculis, hendrerit dui ac, porta eros. Etiam tempor vehicula rutrum. Vivamus cursus leo eu nulla vehicula hendrerit.
    </div>
  </div>

  <div id="sideMenuItem2" class="chapterMod">
    <div id="IDS_navItemLabel3" class="moduleBtn">
      <a href="#">THREE</a>
    </div>
    <div id="IDS_Section2Chapter1" class="boxBtn">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in metus non felis semper egestas. Donec pharetra erat nisi, vel maximus ex rhoncus vel. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam sit amet aliquet nunc. Quisque cursus sem a varius sollicitudin. Aenean a vulputate enim. Proin pharetra, tortor id semper imperdiet, metus turpis laoreet velit, ut vehicula orci magna sed massa. Phasellus tincidunt lectus mattis pellentesque porttitor. Donec at mauris sit amet leo pellentesque eleifend. Nullam at elit iaculis, hendrerit dui ac, porta eros. Etiam tempor vehicula rutrum. Vivamus cursus leo eu nulla vehicula hendrerit.
    </div>
  </div>

  <div id="sideMenuItem3" class="chapterMod">
    <div id="IDS_navItemLabel4" class="moduleBtn">
      <a href="#">FOUR</a>
    </div>
    <div id="IDS_Section3Chapter1" class="boxBtn">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in metus non felis semper egestas. Donec pharetra erat nisi, vel maximus ex rhoncus vel. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nullam sit amet aliquet nunc. Quisque cursus sem a varius sollicitudin. Aenean a vulputate enim. Proin pharetra, tortor id semper imperdiet, metus turpis laoreet velit, ut vehicula orci magna sed massa. Phasellus tincidunt lectus mattis pellentesque porttitor. Donec at mauris sit amet leo pellentesque eleifend. Nullam at elit iaculis, hendrerit dui ac, porta eros. Etiam tempor vehicula rutrum. Vivamus cursus leo eu nulla vehicula hendrerit.
    </div>
  </div>

</div>
              
            
!

CSS

              
                .sidemenu {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
}

.moduleBtn {
  display: block;
  margin-left: 0;
  cursor: pointer;
  text-align: center;
  width: 100%;
  padding: 1.4em 1.4em 1em;
  background-color: #000;
  box-sizing: border-box;
  font-weight: bold;
}

.moduleBtn:hover {
  background-color: #ffc423;
}

.moduleBtn:hover a {
  color: #000!important;
}

.moduleBtn a:link {
  text-decoration: none;
  font-size: 1.25em;
  line-height: 100%;
  color: #FFF;
  text-align: center;
  width: 100%;
}

.moduleBtn a:visited {
  color: #FFF;
}

.moduleBtn a:hover {
  color: #FFF;
}

.moduleBtn a:active {
  color: #FFF;
}

.boxBtn {
  display: block;
  cursor: pointer;
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
  font-size: .8em;
  background-color: #CCC;
  padding: 1em;
  box-sizing: border-box;
}
              
            
!

JS

              
                // HOVER: give each .moduleBtn element its own timeline animation

$(".moduleBtn").each(function(index, element) {
  var tl = new TimelineLite({
    paused: true
  });

  tl.to($(element).find("a"), 0.15, {
    color: "rgba(255,255,255,1)"
  }, 0);
  element.hvranimation = tl;
});

//give each .boxBtn element its own timeline animation
$(".boxBtn").each(function(index, element) {
  var tl = new TimelineLite({
    paused: true
  });
  tl.to($(element).find("a"), 0.15, {
    color: "rgba(255,255,255,1)"
  }, 0);
  element.hvranimation = tl;
});

function over() {
  if ($(this).hasClass("activeMod") || $(this).hasClass("activeChap")) {
    // hover not needed if already active (selected)
  } else {
    this.hvranimation.play();
  }
}

function out() {
  if ($(this).hasClass("activeMod") || $(this).hasClass("activeChap")) {
    // hover not needed if already active (selected)
  } else {
    this.hvranimation.reverse();
  }
}

//toggle play and reverse of each button element's timeline on hover 
$(".moduleBtn").hover(over, out);
$(".boxBtn").hover(over, out);

//  END HOVER

// ACCORDION MENU ACTION
var $sideMenuGroup = $("#sidemenu").find(".chapterMod");
var $sidemenuLi = $("#sidemenu").find(".moduleBtn");
var $chapterLi = $("#sidemenu").find(".boxBtn");

$sidemenuLi.click(function(event) {
  event.preventDefault();
  var $this = $(this);

  // get the chapterMod div so we can expand selected group and colapse others
  var thisModGrp = $(this).parent()[0];

  var tlboxBtn = new TimelineLite({
    paused: true
  });

  $(".boxBtn").each(function(index, element) {
    if ($(element).parent()[0] == thisModGrp) {
      tlboxBtn.to($(element), 0.25, {
        autoAlpha: 1,
        height: 100,
        paddingTop:20,
        paddingBottom:20
      }, 0);
    } else {
      tlboxBtn.to($(element), 0.25, {
        autoAlpha: 0,
        height: 0,
        paddingTop:0,
        paddingBottom:0
      }, 0);
    }

    element.grpanimation = tlboxBtn;
    element.grpanimation.play();
  });

  var newModClick = new TimelineLite({
    paused: true
  });

  // this next line seems unnecessary since adding and removing the "activeMod" class should revert the alpha but it does not.
  newModClick.to($sidemenuLi.filter(".activeMod").find("a"), 0, {
    color: "rgba(255,255,255,1)"
  }, 0);

  newModClick.to($sidemenuLi.filter(".activeMod"), 0, {
    className: "-=activeMod"
  }, 0);
  newModClick.to($this, 0.25, {
    className: "+=activeMod"
  }, 0);
  newModClick.play();
});

// END ACCORDION MENU ACTION

// MENU CHAPTER SELECTION
$chapterLi.click(function(event) {
  event.preventDefault();
  var $this = $(this);

  var newClick = new TimelineLite({
    paused: true
  });

  // this next line seems unnecessary since adding and removing the "activeMod" class should revert the alpha but it does not.
  newClick.to($chapterLi.filter(".activeChap").find("a"), 0, {
    color: "rgba(255,255,255,1)"
  }, 0);
  newClick.to($chapterLi.filter(".activeChap"), 0, {
    className: "-=activeChap"
  }, 0);
  newClick.to($this, 0.15, {
    className: "+=activeChap"
  }, 0);
  newClick.play();

});

// END MENU CHAPTER SELECTION

// close the menu on init
$sidemenuLi.click();
              
            
!
999px

Console