123

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.

            
              ul
    li
        a(href='#') Parent 1
    li
        a(href='#') _Child 1
    li
        a(href='#') _Another Child
    li
        a(href='#') _Child 3
    li
        a(href='#') __Granddhild 1
    li
        a(href='#') __Grandchild 2
    li
        a(href='#') _And A Longer Child
    li
        a(href='#') Parent 2
    li
        a(href='#') _First Child
    li
        a(href='#') _Second Child
    li
        a(href='#') Item 1        
    li
        a(href='#') Parent 3
    li
        a(href='#') _Child 1
    li
        a(href='#') _Child 2
    li
        a(href='#') _Child 3
    li
        a(href='#') __Grandchild 1
    li
        a(href='#') __Grandchild 2
    li
        a(href='#') _Child 4
    li
        a(href='#') _Child 5
    li
        a(href='#') __Grandchild 1
    li
        a(href='#') __Grandchild 2
    li
        a(href='#') Item 2
    li
        a(href='#') Item 3
            
          
!
            
              // SETTINGS
//---------------------------------------------------------

// Menu Collapse, change to something above viewport width to see responsive version
$toggle: 700px;

// Main Bar Background Color
$menu_bg: #B50A50;

// Link Color and Hover
$menu_color: white;
$item_hover_color: lighten($menu_bg, 75%);

// Drop Down Opener (Arrow Links)
$arrow_toggle_line: 1px solid rgba(white, .1);
$arrow_toggle_hover_bg: rgba(white, .1);
$arrow_toggle_color: white;

// Level Two Background and Background on hover
$level-two_bg: $menu_bg;
$level-two_hover_bg: rgba(white, .1);

// Level Three Background and Background on hover
$level-three_bg: $menu_bg;
$level-three_hover_bg: rgba(white, .1);

// Menu Text Alignment use[left, center, right]
$text_align: left; 

// Responsive Toggle Link
$responsive_width: 100%;
$responsive_toggle_text_align: left;
$navtoggle_bg: #291018;
$navtoggle_color: white;
$navtoggle_hover_color: lighten(#291018, 80%);


// STYLES
//-----------------------------------------------------------------
// general styles
/* do not copy this, scroll further */
body{
    line-height: 1.2;
    background: #34364F;
    font:{
        family: 'Droid Sans', 'Calibri', 'Arial', sans-serif;
        size: 16px;
    }    
}

.container{
    width: 80%;
    max-width: 1300px;
    background: #F5F7F6;
    margin: 80px auto;
    padding: 30px;
    box-sizing: border-box;
}

header{
    padding: 80px 0;
}

p{        
    margin: 10px 0px;    
}
    
h1{
    font:{
        size: 100px;
        family: 'Old Standard';
    }
    color: #A62030;
    text-transform: uppercase;
    letter-spacing: 30px;
    text-align: center;
}

a{    
    text-decoration: none;    
    transition: .3s all ease;
}

// Navigation
/* Copy Everything Below This Line */
.menu{
    background: $menu_bg;
    width: 100%;
    padding: 3px 7px;
    box-sizing: border-box;
    text-align: $text_align;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;

    ul,
    li{
        margin: 0;
        padding: 0;
    }
    
    // Basic Link styling
    a{
        color: $menu_color;
        
        &:hover,
        &:focus{
            color: $item_hover_color;
        }
    }
    
    // first level
    > ul{
        width: 100%;
        position: relative;
        display: inline-block;
        
        li{
            display: inline-block;
            padding: 10px 7px;
        }
    }
    
    // Drop Down Toggle Links
    .fa{
        border: $arrow_toggle_line;
        border-radius: 2px;
        padding: 3px 0px;
        color: $arrow_toggle_color;
        margin: 0 10px;
        
        a{
            font-size: 0;
            padding: 0 !important;
        }
        
        &:hover,
        &:focus{
            background: $arrow_toggle_hover_bg;
            cursor: pointer;
        }
    }
    
    // Second Level
    .level-two{
        display: none;
        position: absolute;
        background: $level-two_bg;
        top: 100%;
        left: auto;
        
        > li{
            display: block;
            background: transparent;
            padding: 0;
            transition: .3s all ease;
            position: relative;
            white-space: nowrap;
            
            &:hover,
            &:focus{
                background: $level-two_hover_bg;
            }
            
            a{
                width: 100%;
                display: block;
                padding: 10px 7px;
                box-sizing: border-box;
            }
        }
        
        // List Items with Sub Menus
        .sharewidth{            
            > a{
                display: inline-block;
                width: auto;
            }
        }
    }
    
    .level-three{
        display: none;
        position: absolute;
        left: 100%;
        top: 0;
        background: $level-three_bg;
        
        li{
            display: block;
            background: transparent;
            padding: 0;
            transition: .3s all ease;
            position: relative;
            white-space: nowrap;
            
            &:hover,
            &:focus{
                background: $level-three_hover_bg;
            }
        }
    }
}

// Toggle Link
@media screen and (min-width: $toggle + 1){
    .navtoggle{
        display: none;
    }
}

// Responsive Version
@media screen and (max-width: $toggle){
    .outside{
        position: fixed;
        top: 0px;
        left: 0px;
        width: $responsive_width;
        padding: 10px;
        box-sizind: border-box;
        text-align: $responsive_toggle_text_align;
        z-index: 10;
        background: $navtoggle_bg;
        color: $navtoggle_color;
        
        &:hover,
        &:focus{
            color: $navtoggle_hover_color;
            cursor: pointer;
        }        
    }
    
    .menu{
        position: fixed;
        height: 100%;
        top: 0;
        left: -320px;
        overflow-y: auto;
        overflow-x: hidden;
        transform: translate(0 0);
        max-width: 320px;
        transition: .3s all ease;
        
        .navtoggle{
            position: relative;
            top: 0;
            right: 0;
            left: 0;
            display: block;
            text-align: right;
            font-size: 0;
            
            .fa{
                font-size: 20px;
                border: 0 solid transparent;
                
                &:hover,
                &:focus{
                    background: transparent;
                    opacity: .5;        
                }
            }
        }
        
        &.active{
            transform: translateX(320px);
            transition: .3s all ease;
        }
        > ul li{
            display: block;            
        }
        
        .level-two,
        .level-three{
            position: relative;
            left: 0;
            top: 0;
        }        
    }
}
            
          
!
            
              $(function() {

    // SETTINGS
    //------------------------------------------------------    
    var one_level_list_element = $('ul'), // mandatory!
        menu_name = 'Menu', // this will be used next to the hamburger icon for the toggle Button
        menu_wrapper_class = 'menu',
        parent_item_class = 'parent',
        child_item_class = 'child-item',
        grandchild_item_class = 'grandchild-item',
        children_wrapper_class = 'level-two',
        grandchildren_wrapper_class = 'level-three';

    // DOM SETUP
    //------------------------------------------------------

    // locate children and grandchildren and store in variable
    var grandchild = $('li a:contains("__")'),
        child = $('li a:contains("_")');

    // if list wrapper has no class add class nav, otherwise store class in variable
    if (one_level_list_element.attr('class') == undefined) {
        one_level_list_element.addClass('nav');
        var ul_wrapper = 'nav';
    } else {
        var ul_wrapper = one_level_list_element.attr('class');
    }

    // Add class to child items
    child.parent().addClass(child_item_class);

    // wrap children in ul
    var citem = $('.' + child_item_class);
    for (var i = 0; i < citem.length;) {
        i += citem.eq(i).nextUntil(':not(.' + child_item_class + ')').andSelf().wrapAll('<ul></ul>').length;
    }
    citem.parent().addClass(children_wrapper_class);

    // add class to grandchildren
    grandchild.parent().addClass(grandchild_item_class);

    // wrap grandchildren in ul
    var gitem = $('.' + grandchild_item_class);
    for (var i = 0; i < gitem.length;) {
        i += gitem.eq(i).nextUntil(':not(.' + grandchild_item_class + ')').andSelf().wrapAll('<ul></ul>').length;
    }
    gitem.parent().addClass(grandchildren_wrapper_class);

    // add class to parents
    $('.' + ul_wrapper + ' > li').addClass(parent_item_class);

    // remove underscores from Names
    $('.' + ul_wrapper + ' a').each(function() {
        $(this).text($(this).text().replace(/_/g, ' '));
    });

    // append Grandchildren to Children
    $('.' + children_wrapper_class + ' > .' + child_item_class).each(function() {
        if ($(this).next().is('.' + grandchildren_wrapper_class)) {
            $(this).next().appendTo($(this));
        }
    });

    // append Children to parents
    $('.' + ul_wrapper + ' > .' + parent_item_class).each(function() {
        if ($(this).next().is('.' + children_wrapper_class)) {
            $(this).next().appendTo($(this));
        }
    });

    // wrap navigation in div container
    $('.' + ul_wrapper).wrap('<div class="' + menu_wrapper_class + '"></div>');

    // add toggle Links to open and close (uses Font-Awesome)
    $('.' + menu_wrapper_class).before('<span class="navtoggle outside"><i class="fa fa-navicon"></i> ' + menu_name + '</span>');

    $('.' + menu_wrapper_class).prepend('<span class="navtoggle"><i class="fa fa-close"></i></span>');

    // add toggle open link for level one and two (uses FontAwesome again)
    $('.' + children_wrapper_class).before('<i class="fa fa-fw fa-angle-down"></i>');
    $('.' + grandchildren_wrapper_class).before('<i class="fa fa-fw fa-angle-right"></i>');

    // now the basic HTML structure is created, we are ready to care about the menu functionality now

    // MENU STUFF
    //------------------------------------------------------

    // Open function for parents
    $('.fa-angle-down').click(function() {
        if ($(this).siblings('.' + children_wrapper_class).is(':hidden')) {
            $('.' + menu_wrapper_class + ' .' + children_wrapper_class).slideUp();
            $(this).siblings('.' + children_wrapper_class).slideToggle();
        } else {
            $(this).siblings('.' + children_wrapper_class).slideUp();
        }
    });

    // Open function for children
    $('.fa-angle-right').click(function() {
        if ($(this).siblings('.' + grandchildren_wrapper_class).is(':hidden')) {
            $('.' + menu_wrapper_class + ' .' + grandchildren_wrapper_class).slideUp();
            $(this).siblings('.' + grandchildren_wrapper_class).slideToggle();
        } else {
            $(this).siblings('.' + grandchildren_wrapper_class).slideUp();
        }
    });

    // toggle active Class to open and close off-canvas Menu 
    // also change the angled icon's direction for children
    $('.navtoggle').click(function() {
        $('.' + menu_wrapper_class).toggleClass('active');
        $('.' + children_wrapper_class + ' .fa').toggleClass('fa-angle-right, fa-angle-down');
    });

    // add class to child-item which has Grandchildren 
    // (so that toggle and link can be placed on one line)
    if ($('li > .fa-angle-right').length > 0) {
        $('li > .fa-angle-right').parent().addClass('sharewidth');
    }

    // grab the menu's height
    var menuheight = $('.' + menu_wrapper_class).outerHeight();

    // add this height as a margin to the body, so that the menu won't cover everything up.
    $('body').css('margin-top', menuheight + 10)
});
            
          
!
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.

Console