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.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

Behavior

Auto Save

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                  <span id="menu-icon"><a href="#">Menu</a></span> 

<div class="row">
  <nav id="leftnav" class="small-12 medium-2 columns">

		<ul>
      <li class="hasDropdown"><a href="football-tops">Football Kits<span class="open-icon">+</span></a>
					<ul class="subnav">
								<li><a href="#">Tracksuits</a></li>
								<li><a href="#">Training Wear</a></li>
								<li><a href="#">Jackets</a></li>
								<li><a href="#">Tracksuits</a></li>
								<li><a href="#">Jackets</a></li>
								<li><a href="#">Goalkeeper</a></li>
					</ul>
					</li>
			<li class="hasDropdown"><a href="#">Goalkeeper<span class="open-icon">+</span></a>
								<ul class="subnav">
								<li><a href="#">Goalkeeper kit</a></li>
								<li><a href="#">Goalkeeper kit for men</a></li>
								<li><a href="#">Goalkeeper kit for kids</a></li>
								<li><a href="#">Tracksuits</a></li>
								<li><a href="#">Goalkeeper stuff</a></li>
								<li><a href="#">Goalkeeper</a></li>
					</ul>
</li>
			<li class="hasDropdown"><a href="#">Tracksuits<span class="open-icon">+</span></a>
								<ul class="subnav">
								<li><a href="#">Tracksuit bits</a></li>
								<li><a href="#">Tracksuit bottoms</a></li>
								<li><a href="#">Girls tracksuits</a></li>
								<li><a href="#">Tracksuits for kids</a></li>
					</ul>
			<li><a href="#">Jackets</a></li>
			<li><a href="#">Tracksuits</a></li>
			<li class="hasDropdown"><a href="#">Training Wear<span class="open-icon">+</span></a>
								<ul class="subnav">
								<li><a href="#">Training Wear for men</a></li>
								<li><a href="#">Training Wear </a></li>
								<li><a href="#">New lines for 2015</a></li>
								<li><a href="#">Rugby </a></li>
								<li><a href="#">Football </a></li>
								<li><a href="#">Training Wear for men</a></li>
								<li><a href="#">Training Wear </a></li>
								<li><a href="#">New lines for 2015</a></li>
								<li><a href="#">Rugby </a></li>
								<li><a href="#">Football </a></li>
					</ul>
			<li><a href="#">Jackets</a></li>
			<li><a href="#">FAQ</a></li>
			<li><a href="#">T &amp; C's</a></li>
			<li><a href="#">Contact</a></li>
		</ul>

	</nav>

<div class="small-12 medium-10 columns hero">
  <img src="http://lorempixel.com/output/fashion-q-c-939-527-7.jpg" class="heroimg">
</div>
  
</div><!-- end row -->
              
            
!

CSS

              
                *, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

.row {
width: 100%;
margin-left: auto;
margin-right: auto;
margin-top: 12px;
margin-bottom: 0;
}

.medium-2 {
  width:20%;
  float:left;
}

.medium-10 {
  width: 70%;
  float:right;
}

.open-icon {
  float:right;
  padding: 10px;
}

#leftnav {
  display: block;

}
#leftnav ul {
  margin-top: 0px;  
  top: 0px;
}
#leftnav ul li {
  list-style-type: none;
}
#leftnav>ul>li a {
font-family: 'Open Sans',Arial,sans-serif;
color: #1A3062;
background: #f2f2f2;
  border-bottom: solid 1px #bbb;
padding: 0.225rem;
width: 100%;
display: block;
font-weight: 600;
text-transform: uppercase;
font-size: 0.9rem;
}

.subnav {
display: none;
position: absolute;
top: 0;
z-index: 90;
background-color: #1A3062 !important;
height: 100%;
border-right: solid 0.875rem white;
}

.subnav {
display: none;
position: absolute;
top: 0;
z-index: 90;
background-color: #1A3062 !important;
height: 100%;
border-right: solid 0.875rem white;
}
.subnav li a {
background: #1A3062 !important;
color: white !important;
font-size: 0.875rem;
font-weight: 100 !important;
}

.heroimg {
  width: 60%;
}


#menu-icon {
   display:none;
}

@media only screen and (max-width: 1024px) {
#leftnav {
width: 100% !important;
display: none;
padding-left: 0px !important;
padding-right: 0px !important;
}

  .medium-10, .medium-2 {
    width: 100%;
  }
  #menu-icon {
    display:block;
  }
  
  .subnav {
position: static;
top: auto;
height: auto;
border-right: none;
}
  
}
              
            
!

JS

              
                function layoutPosition() {

	var numOfLis = $("#leftnav li").not(".subnav li").length;
	var heroImg = $(".heroimg").height();
	var linkHeight = $("#leftnav li").height();
	var theBg = $(".hasDropdown").children("a").css("background");
	var bigCheck = true;
	var smallCheck = false;
	var menuIcon = $("#menu-icon");

		// slide down the mobile menu
		$("#menu-icon").off('click').click(function() {
        $("#leftnav").slideToggle("fast");
		});


	if (menuIcon.is(":visible")) {
      bigCheck = false;
      smallCheck = true;
	} else {
      bigCheck = true;
      smallCheck = false;
	} // end if window size


	if (bigCheck) {
          smallCheck = false;
          $("#leftnav").show();
          //if the hero image (main slider image) is over 100px, set the menu to match that height
          if (heroImg >= 100) { 
            var lisHeight = $("#leftnav li").css("height", (heroImg / numOfLis) + "px");
            var asHeight = $("#leftnav li a").css("height", (heroImg / numOfLis) + "px");
          }

				$(".hasDropdown").hover(function() {
            var thisLeft = $(this).position().left;
            var thisWidth = $(this).width();
            var thisHeight = (numOfLis * linkHeight) + "px";
            var pos = thisLeft + thisWidth - 15;
            var theSubnav = $(this).children().next(".subnav");
            $(this).children("a").css("background", "#1A3062").css("color", "white");
            theSubnav.css("left", pos);
              if (heroImg >= 100) {
                theSubnav.css("height", heroImg);
              } else {
                theSubnav.css("height", thisHeight);
              }
            theSubnav.show();
        }, function() {
            var theSubnav = $(this).children().next(".subnav");
            theSubnav.fadeOut("fast");
            $(this).children("a").css("background", theBg).css("color", "#1A3062");
						  });	

	} //end bigCheck

	if (smallCheck) {
      bigCheck = false;
      $(".hasDropdown").off("mouseenter mouseleave");
        var lisHeight = $("#leftnav li").css("height", "auto");
        var asHeight = $("#leftnav li a").css("height", "auto");

    $(".hasDropdown .open-icon").off("click").click(function() {
            var theSubnav = $(this).parents().children().next(".subnav");
            theSubnav.slideToggle("fast");
        return false;
      });

	} // end smallCheck

}
$(document).ready(layoutPosition); // the above function should fire on both initial load...

$(window).resize(layoutPosition); //...and everytime the window is resized.
              
            
!
999px
A Pen is worth a thousand docs.

Console