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

              
                <header> 
	<h2>Sticky navigation bar w/ subitems</h2>
</header>

<nav class="navbar">
	<ul> 
		<li><a href="#">First</a></li>
		<li><a href="#">Second <span style="font-size:0.7em;">&#x25BC;</span></a>
			<ul class="subnav">
				<li><a href="#">subitem 2.1</a></li>
				<li><a href="#">subitem 2.2</a></li>
				<li><a href="#">subitem 2.3</a></li>
			</ul>
		</li>
		<li><a href="#">Third <span style="font-size:0.7em;">&#x25BC;</span></a>
			<ul class="subnav">
				<li><a href="#">subitem 3.1</a></li>
				<li><a href="#">subitem 3.2</a></li>
			</ul>
		</li>
		<li><a href="#">Fourth</a></li>
	</ul>
</nav>

<div class="content">
	<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec ipsum massa, ullamcorper in, auctor et, scelerisque sed, est. Praesent in mauris eu tortor porttitor accumsan. Mauris elementum mauris vitae tortor. Suspendisse sagittis ultrices augue. Nunc dapibus tortor vel mi dapibus sollicitudin. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Vivamus luctus egestas leo. Duis ante orci, molestie vitae vehicula venenatis, tincidunt ac pede. Integer malesuada. Cras elementum.</p>
	<p>Integer lacinia. Etiam neque. Fusce dui leo, imperdiet in, aliquam sit amet, feugiat eu, orci. Fusce aliquam vestibulum ipsum. In convallis. Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. Integer rutrum, orci vestibulum ullamcorper ultricies, lacus quam ultricies odio, vitae placerat pede sem sit amet enim. Etiam neque. Praesent vitae arcu tempor neque lacinia pretium. Duis risus. Aliquam in lorem sit amet leo accumsan lacinia. Morbi scelerisque luctus velit. Phasellus faucibus molestie nisl.</p>
</div>
              
            
!

CSS

              
                body { 
	font-family: "Futura", sans-serif;
	height: 1400px;
	min-width: 512px;
  background: linear-gradient(#fff,#fff,#9cc);
}
header {
	text-align: center;
	background-color: #ddd;
  background: -webkit-linear-gradient(#ccc,#eee,#eee,#ccc);
  background: -o-linear-gradient(#ccc,#eee,#eee,#ccc);
  background: -moz-linear-gradient(#ccc,#eee,#eee,#ccc);
  background: linear-gradient(#ccc,#eee,#eee,#ccc);
}
h2 { 
	font-size: 2em;
	line-height: 3.2em;
	text-shadow: 1px 1px 4px #788;
}

.navbar {	
  text-align: center;
	width: 100%;
	padding: 18px 0;
	background-color: #088; 
  background: -webkit-linear-gradient(#099, #066, #055);
  background: -o-linear-gradient(#099, #066, #055);
  background: -moz-linear-gradient(#099, #066, #055);
  background: linear-gradient(#099, #066, #055);
}
.navbar ul {
  letter-spacing: 1px;
	max-width: 1280px;
	margin: 0 auto;
	display: block; 
  list-style-type: none;
}
.navbar > ul > li {
	display: inline-block;
	margin: 0 8px;
	font-size: 1.2em;
} 
.navbar li a {
	text-decoration: none;
	color: white;
	overflow: hidden;
	position: relative;
	padding: 16px;
	text-shadow: 0px 1px 2px #000;
}
.navbar > ul > li:hover > a { 
	color: #000;
	text-shadow: 0px 1px 2px #688;
}

.navbar li:hover ul { display: block; }

ul.subnav {
	min-width: 66px;
	margin-top: 16px;
	display: none;
	position: absolute;
	font-size: 0.9em;
	background-color: #099;
  background: -webkit-linear-gradient(#055, #066, #099);
  background: -o-linear-gradient(#055, #066, #099);
  background: -moz-linear-gradient(#055, #066, #099);
  background: linear-gradient(#055, #066, #099);
	border-bottom-left-radius: 4px;
	border-bottom-right-radius: 4px;
	overflow: hidden;
}
.subnav li { display: block; }
.subnav li a {
	padding: 8px;
	display: block;
}
.subnav li:hover {
	background-color: #111;
  background: -webkit-linear-gradient(#111,#333,#222,#000);
  background: -o-linear-gradient(#111,#333,#222,#000);
  background: -moz-linear-gradient(#111,#333,#222,#000);
  background: linear-gradient(#111,#333,#222,#000);
}

/* for fixing anything on top */
.fixed {
	position: fixed;
	top: 0;
}

.content {
	text-align: justify;
	padding: 32px 5%;
}
.content p { margin-bottom: 16px; }
              
            
!

JS

              
                $(document).scroll(function() {
  
	if ($(document).scrollTop() > $('header').height()) {
    $('.navbar').addClass('fixed');
    $('.content').css('margin-top', '54px');
  }
  else if ($('.navbar').hasClass('fixed')) {
    $('.navbar').removeClass('fixed');
    $('.content').css('margin-top', '0px');
  }
}); 

              
            
!
999px

Console