css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <main>
  <h2>CSS Dropdown Menu</h2>
  <nav>
    <div class="dropdown hover">
      <a href="#">Hover Menu</a>
      <ul>
        <li><a href="#">Item</a></li>
        <li><a href="#">Product</a></li>
        <li><a href="#">Text</a></li>
        <li><a href="#">Page</a></li>
        <li><a href="#">Thing</a></li>
        <li><a href="#">Product</a></li>
        <li><a href="#">Text</a></li>
      </ul>
    </div>
    <div class="dropdown toggle">
      <input id="t1" type="checkbox" checked>
      <label for="t1">Toggle Menu</label>
      <ul>
        <li><a href="#">Item</a></li>
        <li><a href="#">Product</a></li>
        <li><a href="#">Text</a></li>
        <li><a href="#">Page</a></li>
        <li><a href="#">Thing</a></li>
      </ul>
    </div>
  </nav>
  <section>
    <h4>The hover menu is pure CSS.</h4>
    <h4>The toggle menu utilizes a minimal amount of javascript, but will degrade gracefully because it only uses javascript to close the menu when the user clicks outside of the menu.</h4>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam urna eros, aliquet id dui at, mollis molestie lorem. Donec consectetur lorem elit, nec cursus neque interdum a. Mauris molestie ut dui eget suscipit. Ut ante risus, rhoncus eget metus sit amet, euismod sodales dui. Suspendisse potenti. Aliquam risus magna, euismod quis sagittis quis, convallis id metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
    </p>
    <p>
      Integer et lacinia erat, vel aliquam magna. Pellentesque sagittis commodo rutrum. Nam dignissim, est fermentum rutrum molestie, arcu odio tempus tortor, a rutrum mauris diam at sapien. Aliquam in enim convallis, feugiat lectus in, rutrum nibh. Vivamus sollicitudin odio vel velit pulvinar tincidunt. Aenean nulla velit, consectetur a risus eu, consequat dictum dui. In suscipit dolor magna, id mollis arcu interdum et. Nunc vel nunc ut velit vulputate imperdiet. Aenean nisl dui, pharetra et blandit quis, condimentum id est.
    </p>
		<p>
			An original pen by <a href="https://codepen.io/ejsado/">Eric</a>.
		</p>
  </section>
</main>

            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700);

body {
  font-family: "Open Sans", "Arial";
  background: #0097B2;
}
h2 {
  color: #FFF;
}
h4 {
  color: #666;
}
p {
  color: #333;
  font-size: 13px;
}
main {
  margin: 50px auto;
  width: 500px;
}
section {
  margin-top: 30px;
  background: #E3F9F9;
  padding: 20px;
  box-shadow: 0 3px 5px rgba(0,0,0,0.15);
}
.dropdown {
  width: 230px;
  display: inline-block;
  margin-right: 10px;
  position: relative;
}
.dropdown.toggle > input {
  display: none;
}
.dropdown > a, .dropdown.toggle > label {
  border-radius: 2px;
  box-shadow: 0 6px 5px -5px rgba(0,0,0,0.3);
}
.dropdown > a::after, .dropdown.toggle > label::after {
  content: "";
  float: right;
  margin: 15px 15px 0 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 10px solid #CCC;
}
.dropdown ul {
  list-style-type: none;
  display: block;
  margin: 0;
  padding: 0;
  position: absolute;
  width: 100%;
  box-shadow: 0 6px 5px -5px rgba(0,0,0,0.3);
  overflow: hidden;
}
.dropdown a, .dropdown.toggle > label {
  display: block;
  padding: 0 0 0 10px;
  text-decoration: none;
  line-height: 40px;
  font-size: 13px;
  text-transform: uppercase;
  font-weight: bold;
  color: #999;
  background-color: #FFF;
}
.dropdown li {
  height: 0;
  overflow: hidden;
  transition: all 500ms;
}
.dropdown.hover li {
  transition-delay: 300ms;
}
.dropdown li:first-child a {
  border-radius: 2px 2px 0 0;
}
.dropdown li:last-child a {
  border-radius: 0 0 2px 2px;
}
.dropdown li:first-child a::before {
  content: "";
  display: block;
  position: absolute;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid #FFF;
  margin: -10px 0 0 30px;
}
.dropdown a:hover, .dropdown.toggle > label:hover, .dropdown.toggle > input:checked ~ label {
  background-color: #EEE;
  color: #666;
}
.dropdown > a:hover::after, .dropdown.toggle > label:hover::after, .dropdown.toggle > input:checked ~ label::after {
  border-top-color: #AAA;
}
.dropdown li:first-child a:hover::before {
  border-bottom-color: #EEE;
}
.dropdown.hover:hover li, .dropdown.toggle > input:checked ~ ul li {          
  height: 40px;
}
.dropdown.hover:hover li:first-child, .dropdown.toggle > input:checked ~ ul li:first-child {
  padding-top: 15px;
}
            
          
!
            
              // close the toggle menu if user clicks outside of the menu

$(document).click(function(event) {
  if(
    $('.toggle > input').is(':checked') &&
    !$(event.target).parents('.toggle').is('.toggle')
  ) {
    $('.toggle > input').prop('checked', false);
  }
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console