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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <div class="container">
<ul id="menu-simple-menu" class="side-nav-bar accordion-menu ">
  <li id="item-1" class="submenu item active">
    <a href="#">Home</a>
    <i class="icon open minus"></i>
  </li>

  <ul class="" style="display: block;">
	  <li id="item-11" class="item"><a href="#">Blog</a></li>
  </ul>
  
  <li id="item-2" class="item"><a href="#">Sample Page</a></li>
  <li id="item-3" class="item"><a href="#">Page B</a></li>
  <li id="item-4" class="item"><a href="#">Page A</a></li>
  <li id="item-5" class="submenu item">
    <a href="#">Level 1</a>
    <i class="add icon open"></i>
  </li>

  <ul>
	  <li id="item-51" class="item"><a href="#">Level 2a</a></li>
	  <li id="item-52" class="submenu item">
      <a href="#">Level 2</a>
      <i class="add icon open"></i>
    </li>

	  <ul>
		  <li id="item-521" class="item"><a href="#">Level 3b</a></li>
		  <li id="item-522" class="item"><a href="#">Level 3a</a></li>
	  </ul>
  </ul>
</ul>
</div>
              
            
!

CSS

              
                html {
  background-color: #f1f1f1;
}

@font-face {
	font-family: 'Icons';
	src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT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ACAAYgB5ACAASQBjAG8ATQBvAG8AbgAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) format('woff');
	font-weight: normal;
	font-style: normal;
}

.icon {
	font-family: 'Icons';
  font-size: .9em;
	speak: none;
	font-style: normal;
	font-weight: normal;
	font-variant: normal;
	text-transform: none;
	line-height: 1;

	/* Better Font Rendering =========== */
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.add:before {
	content: "\e6fc";
}
.minus:before {
	content: "\e6fb";
}



.accordion-menu {
    margin: 1rem 0rem;
    padding: 0;
    list-style: none;
    background-color: transparent;
    -webkit-box-shadow: none;
    box-shadow: none;
    border-radius: 0;
    font-family: Play, Verdana, sans-serif;

    /*    Optional */
    width: 300px;
}

.accordion-menu .item a {
    display:block;
    padding: .83em .95em;
    height: auto!important;
    line-height: 1;
}

.accordion-menu .item {
    position: relative;
    font-size: 1.125rem;
    display: block;
    border-top: 0;
    border-left: 0 solid rgba(0,0,0,0);
    border-right: 0;
    border-top: 0 solid rgba(0,0,0,0);
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    vertical-align: middle;
    text-decoration: none;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-transition: opacity .2s ease,background .2s ease,-webkit-box-shadow .2s ease;
    transition: opacity .2s ease,background .2s ease,box-shadow .2s ease;
}

.container {
  width: 400px;
  margin: 50px 0 0 200px;
}

.accordion-menu .item a {
    color: inherit;
    text-decoration: none;
}


.submenu .icon {    
    display: block;
    position: absolute;
    right: 5px;
    top: 1em;
    color: rgba(0,0,0,.25);
}


.submenu.item + ul .active.item:not(.current_page_ancestor )  {
    background-color: #b3296b;
    color: #f1f1f1;
}
.submenu.item + ul .active.item:not(.current_page_ancestor ):hover  {
    background-color: #ea6ba7;
    color: #f1f1f1;
}

.accordion-menu .item:before {
    position: absolute;
    content: '';
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-image: -webkit-linear-gradient(left,rgba(0,0,0,.03) 0,rgba(0,0,0,.1) 1.5em,rgba(0,0,0,.03) 100%);
    background-image: -webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.03)),color-stop(1.5em,rgba(0,0,0,.1)),to(rgba(0,0,0,.03)));
    background-image: linear-gradient(to right,rgba(0,0,0,.03) 0,rgba(0,0,0,.1) 1.5em,rgba(0,0,0,.03) 100%);
}

.accordion-menu > .item.active {
    border-radius: 0;
    -webkit-box-shadow: .2em 0 0 #b3296b inset;
    box-shadow: .2em 0 0 #b3296b inset;
}

.accordion-menu .item:hover {
    cursor: pointer;
    background-color: rgba(0,0,0,.05);
}

.submenu.item + ul {
    padding: 0;
    display: none;

}

.submenu.item + ul .item {
    background-color: rgba(0,0,0,.1);
}

.submenu.item + ul .item:hover {
    background-color: rgba(0,0,0,.15);
}
              
            
!

JS

              
                (function( $ ){	
	
	$.fn.bounceClasses = function( _class, replace, callback ){
		var $target = $(this);
		if( !$target.hasClass( _class ) ){
			var tmp = _class;
			_class = replace;
			replace = tmp;
		}
		
		$target
			.removeClass( _class )
			.addClass( replace );
		
		//Run a callback
		if( callback !== undefined ){
			callback( $(this), replace, _class );
		}
	};	
	
	
    $.fn.XtndAccordion = function(){
    	//get all submenu elements
        var that = this;
        	$accordion = this.find( '.submenu' );  
        
        //Object MenuStatus
        var menuStatus = {
        		"store" : function( $icon, currentClass, toggleClass ){
    	        			$menu = $icon.parent( '.submenu' );
    	                	if( typeof( Storage ) !== undefined ){    	                		
    	                		if( currentClass == 'minus' ){
    	                			localStorage.setItem( $menu.attr( 'id'), 'open');
    	                		} else {
    	                			localStorage.setItem( $menu.attr( 'id'), 'closed');
    	                		}
    	                	}
        				},
        		"check" : function(){
        						var $menuLink = $accordion;
        						if( typeof( Storage ) !== undefined ){
        							$menuLink.each( function( counter, element ){
    	    							if( localStorage.getItem( $( element ).attr( 'id' ) ) !== null ){
    	    								var menuStatus = localStorage.getItem( $( element ).attr( 'id' ) );
    	    								if( menuStatus === 'open' ){    	    									
    	    									$( element ).children( '.icon' ).trigger( 'click' );
    	    								}
    	    							}
    	    						});
        						}
        					}
        };
        
        $.fn.closeSiblings = function ( callback ){
        	$that = $( this );
        	
        	//Add not-close class to current menu, for query destinction
        	$that
        		.addClass( 'not-close')
        		.parents( 'ul' )
        		.addClass( 'not-close');
        	
        	//Choose the othe menus
        	$otherMenus = $( that ).find( '.submenu + ul:not(.not-close)' );
        	
        	//Close every menu is open
        	$otherMenus.each( function( counter, menu ){
        		var $menu = $( menu ),
        			$icon = $menu.prev( '.submenu' ).children( '.icon');       		
        			
        		//if menu is open ( :visible ), close it
        		if( $menu.is( ':visible') ){
        			$icon.bounceClasses( 'add', 'minus', menuStatus.store );
        			$menu.slideToggle( 300 ); 
        		}
        		
        		//if there is a callback run it
        		if( functionExists( callback ) ){
        			callback( $that, $menu, $icon);
        		}
        		
        	});
        	
        	//Remove temporary class
        	$that
	    		.removeClass( 'not-close')
	    		.parents( 'ul' )
	    		.removeClass( 'not-close');   		
        	
    	};
        
        
        //if there are submenu elements, attach the event listener
        if( $accordion && $accordion.length > 0){        	
            $accordion.children( '.icon' ).on( 'click', ToggleSubMenu );
            $accordion.children( '.submenu > a' ).on( 'click', ToggleSubMenu );
        }        
        
        function ToggleSubMenu( evt ){
            var $submenu = $(this).parent( '.submenu' ).next( 'ul'),
            	$target = $( this );         
                
            if( $( this )[0].nodeName === 'A' ){
                $target = $( this ).parent( '.submenu' ).child( '.icon' );
            }
            $target.bounceClasses( 'add', 'minus', menuStatus.store );
            
            $submenu.closeSiblings();
            $submenu.slideToggle( 300 );
        }
        
        function functionExists( functionName){
        	return ( functionName !== undefined ) && ( typeof( functionName ) === "function" );
        }
        
        menuStatus.check();
    };    
})( jQuery );

;( function( $ ){
  //Run functions with the need of jquery support
	$( document ).ready(
			function(){
				$( '.accordion-menu' ).XtndAccordion();			
			}
	);
})(jQuery);
              
            
!
999px

Console