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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                %link{ rel: "stylesheet", href:"https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" }

.dropdown.demo-left
  %a.dropdown__toggle{href:'#', aria: { haspopup: true } }
    Left-aligned Dropdown
    %i.fa.fa-caret-down{ aria: { hidden: true } }
  %ul.dropdown__menu{ style: 'left: 0;' }
    %li.dropdown__menu-item
      %a{ href: '#'}
        1
    %li.dropdown__menu-item
      %a{ href: '#'}
        2
    %li.dropdown__menu-item
      %a{ href: '#'}
        3 
.dropdown.demo-right
  %a.dropdown__toggle{href:'#', aria: { haspopup: true } }
    Right-aligned Dropdown 
    %i.fa.fa-caret-down{ aria: { hidden: true } }
  %ul.dropdown__menu{ style: 'right: 0;' }
    %li.dropdown__menu-item
      %a{ href: '#'}
        One
    %li.dropdown__menu-item
      %a{ href: '#'}
        Two
    %li.dropdown__menu-item
      %a{ href: '#'}
        Three

.vertical-spacing

.dropdown.demo-left
  %a.dropdown__toggle{ href:'#', aria: { label: 'Settings', haspopup: true } }
    %i.fa.fa-caret-down{ aria: { hidden: true } }
  %ul.dropdown__menu{ style: 'left: 0;' }
    %li.dropdown__menu-item
      %a{ href: '#'}
        Uno
    %li.dropdown__menu-item
      %a{ href: '#'}
        Dos
    %li.dropdown__menu-item
      %a{ href: '#'}
        Tres

.dropdown.demo-right
  %a.dropdown__toggle{ href:'#', aria: { label: 'Options', haspopup: true } }
    %i.fa.fa-ellipsis-v{ aria: { hidden: true } }
  %ul.dropdown__menu{ style: 'right: 0;' }
    %li.dropdown__menu-item
      %a{ href: '#'}
        一
    %li.dropdown__menu-item
      %a{ href: '#'}
        二
    %li.dropdown__menu-item
      %a{ href: '#'}
        三

              
            
!

CSS

              
                /* For this Codepen purpose */
body {
  font-family: monospace;
  background-color: #52d2bc;
}

.vertical-spacing {
  height: 300px;
  display: block;
}

.demo-left {
  float: left;
}

.demo-right {
  float: right;
}

/* ****************************************** */
/* Dropdown menu styling */
/* ****************************************** */

.dropdown {
  display: block;
  transition-duration: 0.2s;
  position: relative;
}

.dropdown > a {
  display: block;
  padding: .6em 1em;
}

/* all links */
a {
  display: block;
  height: 100%;
  text-decoration: none;
  color: black;
  padding: .6em 1em;
}

/* menu item */
li.dropdown__menu-item {
 display: block;
 transition-duration: 0.2s;
 position: relative;
}

/* When menu item is hovered, tabbed, or contains child with focus, */
li.dropdown__menu-item:focus,
li.dropdown__menu-item:focus-within,
li.dropdown__menu-item:hover {
  background-color: #b2f1e6;
  cursor: pointer;
}

/* Ensures that hover background won't cover bottom outline of focused item above*/
li.dropdown__menu-item:focus,
li.dropdown__menu-item:focus-within {
  z-index: 1;
}
 
/* Toggle styling when dropdown is focused, hovered, or contains child with focus */
.dropdown:focus,
.dropdown:focus-within,
.dropdown:hover > a.dropdown__toggle {
  text-decoration: underline;
  cursor: pointer;
}

ul.dropdown__menu {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  transition: all 0.2s ease;
  display: none;
  background-color: white;
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 7rem;
/*  When toggle is focused, bottom border cuts off when dropdown is open.   */
  margin-top: 1rem;
}

/* Dropdown menu when dropdown is focused or child element is focused*/
.dropdown:focus > ul.dropdown__menu,
.dropdown:focus-within > ul.dropdown__menu {
  visibility: visible;
  opacity: 1;
  display: block;
}

.dropdown__menu-item {
  clear: both;
  width: 100%;
  text-align: left;
}

              
            
!

JS

              
                // Still would need javascript to add keyboard arrow support, aria-expanded 


              
            
!
999px

Console