octocatstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

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

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              <!DOCTYPE html>
<html lang="en">
<head>

  <title>Template HTML File</title>

</head>
<body>

  <div class="page-wrap">

  	<header>
		<h1>Learning jQuery</h1>
		</header>

		<nav>

			<li><a href="#">Home</a></li>
			<li><a href="#">About</a></li>
			<li><a href="#">Services</a></li>
			<li><a href="#">Forum</a></li>
			<li><a href="#">Contact</a></li>

		</nav>

		<section>

			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
			tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
			quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
			consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
			cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
			proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
			<br />
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
			tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
			quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
			consequat.</p>
			<br />
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
			tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
			quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
			consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
			cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
			proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

		</section>
		
		<footer>
			<p>Copyright &copy; 2012</p>
		</footer>

	</div>

</body>
</html>
            
          
!

CSS

            
              * {
margin: 0;
padding: 0;
border: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border box;
box-sizing: border-box;
}

body {
background: #ccc;
font: 1em Cambria;
}

.page-wrap {
width: 80%;
margin: 30px auto 0 auto;
background: #fff;
padding: 20px;
}

header{
padding: 40px 0;
background: lightgreen;
padding: 10px;
line-height: 80px;
}

h1 {
font-weight: normal;
color: darkgreen;

}

nav {
list-style: none;
background: green;
overflow: hidden;
margin: 10px 0;
}

nav li {
float: left;
}

nav li a {
display: block;
padding: 10px 15px;
text-decoration: none;
color: #fff;
border-right: 2px groove #099f05;
}

.hover {
background: darkgreen;
}

section {
color: #666;
margin: 30px 0;
}

footer {
background: lightgreen;
padding: 10px;
}
            
          
!

JS

            
              $(document).ready(function() {
  var $nav_a = $('nav li a'); 
  // can create $nav_a variable locally as it is not going to vary
  $('nav li a').hover(function() {
     var $this = $(this); 
    // Must create this inside each function, as it will vary.
    $this.toggleClass('hover');
  })
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console