cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

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

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.

            
              div.menu
    ul.nav.level-one
        li
            a(href="#") Item 1
        li.parent
            a(href="#") Item 2 
            label.toggle(for="toggle-level-2-01") o
            input(type="checkbox" id="toggle-level-2-01")
            ul.level-two
                li
                    a(href="#") Child 1
                li
                    a(href="#") Child 2
                li.parent
                    a(href="#") Child 3
                    label.toggle(for="toggle-level-3-01") o
                    input(type="checkbox" id="toggle-level-3-01")
                    ul.level-three
                        li
                            a(href="#") Grandchild 1
                        li.parent
                            a(href="#") Grandchild 2
                            label.toggle(for="toggle-level-4-01") o
                            input(type="checkbox" id="toggle-level-4-01")
                            ul.level-four
                                li
                                    a(href="#") Grandgrandchild 1
                                li
                                    a(href="#") Grandgrandchild 2
                                li
                                    a(href="#") Grandgrandchild 3
        li.parent
            a(href="#") Item 3
            label.toggle(for="toggle-level-2-02") o
            input(type="checkbox" id="toggle-level-2-02")
            ul.level-two
                li
                    a(href="#") Child 1
                li
                    a(href="#") Child 2
                li.parent
                    a(href="#") Child 3
                    label.toggle(for="toggle-level-3-02") o                    
                    input(type="checkbox" id="toggle-level-3-02")
                    ul.level-three
                        li
                            a(href="#") Grandchild 1
                        li
                            a(href="#") Grandchild 2
                        li
                            a(href="#") Grandchild 3
                li
                    a(href="#") Child 4
        li
            a(href="#") Item 4
        li
            a(href="#") Item 5
        li
            a(href="#") Item 6

            

            
          
!
            
              // VARIABLES
//-----------
$font-size: 16px;
$font: Roboto Slab, serif;
$background: #C06574;
$color: white;
$hover-color: #E3DFE6;

// MIXINS
//--------
@mixin triangle($bw, $dir, $c){
    width: 0;
    height: 0;
    border-style: solid;
    @if $dir == right{
        border-color: transparent transparent transparent $c;
    }
    @if $dir == left {
        border-color: transparent $c transparent transparent;
    }
    @if $dir == bottom or $dir == down {
        border-color: $c transparent transparent transparent;
    }
    @if $dir == top or $dir == up {
        border-color: transparent transparent $c transparent;
    }
    border-width: $bw;
}

// STYLING
//---------

.menu {
    font-size: $font-size;
    font-family: $font;
    background-color: $background;
    color: $color;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 0;
    z-index: 10;
    
    // hide checkboxes
    input[type="checkbox"]{
        opacity: 0;
        position: absolute;
        left: -9999px;
    }
    
    // style links
    a{
        color: $color;
        text-decoration: none;
        transition: .3s all ease;
        
        &:hover{
            color: $hover-color;
        }
    }
    
    // style dropdown toggles, with a triangle
    label.toggle{
        color: rgba(0, 0, 0, 0);
        position: relative;
        
        &:hover{
            cursor: pointer;
            &:before{
                @include triangle($font-size/3, right, $hover-color);
            }
        }
        
        &:before{
            content: "";
            font-size: $font-size;
            transition: .3s all ease;
            position: absolute;
            top: 50%;
            left: 5px;
            transform: translateY(0%) rotate(90deg);
            @include triangle($font-size/3, right, $color);
        }
    }
    
    ul{
        position: relative;
        
        // remove list styles
        &,
        li{
            list-style: none;
            padding: 0;
            margin: 0;
        }
        
        // level-one
        > li {
            display: inline;
            padding: 0 10px;
            position: relative;
            

            // level-two
            > ul{
                position: absolute;
                top: calc(100% + 10px); // full height + padding on menu
                left: 0;
                background: $background;
                display: none;
                
                > li{
                    display: block;
                    white-space: nowrap;
                    
                    label.toggle:before{
                        transform: translateY(-50%);
                    }
                } 
               
                // every sublevel 
                ul{
                    left: 100%;
                    top: 0;
                }
            }

            // open submenu based on checkbox state
            input[type="checkbox"]:checked + ul{
                display: block;
            }
        }
    }
}
            
          
!
999px
Loading ..................

Console