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

              
                	<h1>Multi-Level Accordion Menu</h1>
<h2><a href="https://codyhouse.co/demo/multi-level-accordion-menu/animated.html#0">Codyhouse</a></h2>

	<ul class="accordion-collection">
		<li class="has-children">
			<input type="checkbox" name ="group-1" id="group-1" checked>
			<label for="group-1">Group 1</label>

      		<ul>
      			<li class="has-children">
      				<input type="checkbox" name ="sub-group-1" id="sub-group-1">
					<label for="sub-group-1">Sub Group 1</label>

					<ul>
						<li><a href="#0">Image</a></li>
						<li><a href="#0">Image</a></li>
						<li><a href="#0">Image</a></li>
					</ul>
      			</li>
      			<li class="has-children">
      				<input type="checkbox" name ="sub-group-2" id="sub-group-2">
					<label for="sub-group-2">Sub Group 2</label>

					<ul>
						<li class="has-children">
							<input type="checkbox" name ="sub-group-level-3" id="sub-group-level-3">
							<label for="sub-group-level-3">Sub Group Level 3</label>

							<ul>
								<li><a href="#0">Image</a></li>
								<li><a href="#0">Image</a></li>
							</ul>
						</li>
						<li><a href="#0">Image</a></li>
					</ul>
      			</li>
      			<li><a href="#0">Image</a></li>
				<li><a href="#0">Image</a></li>
      		</ul>
		</li>

		<li class="has-children">
			<input type="checkbox" name ="group-2" id="group-2">
			<label for="group-2">Group 2</label>

			<ul>
				<li><a href="#0">Image</a></li>
				<li><a href="#0">Image</a></li>
			</ul>
		</li>

		<li class="has-children">
			<input type="checkbox" name ="group-3" id="group-3">
			<label for="group-3">Group 3</label>

			<ul>
				<li><a href="#0">Image</a></li>
				<li><a href="#0">Image</a></li>
			</ul>
		</li>

		<li class="has-children">
			<input type="checkbox" name ="group-4" id="group-4">
			<label for="group-4">Group 4</label>

			<ul>
				<li class="has-children">
					<input type="checkbox" name ="sub-group-3" id="sub-group-3">
					<label for="sub-group-3">Sub Group 3</label>

					<ul>
						<li><a href="#0">Image</a></li>
						<li><a href="#0">Image</a></li>
					</ul>
				</li>
				<li><a href="#0">Image</a></li>
				<li><a href="#0">Image</a></li>
			</ul>
		</li>
	</ul> <!-- cd-accordion-menu -->
<script src="js/jquery-2.1.4.js"></script>
<script src="js/main.js"></script> <!-- Resource jQuery -->

              
            
!

CSS

              
                @import 'bourbon'; // http://bourbon.io/
// colors

$color-1: #4d5158; // Abbey
$color-2: #a0f6aa; // Gossip
$color-3: #ffffff; // White

// fonts 

$primary-font: 'Jaldi', sans-serif;

// this variable modifies the size of all items

$item-padding-S: 18px;
$item-padding-M: 24px;

$S:     480px;   
$M:     600px;     
$L:     1170px;     

// media queries

@mixin MQ($canvas) {
  @if $canvas == S {
   @media only screen and (min-width: $S) { @content; } 
  }
  @else if $canvas == M {
   @media only screen and (min-width: $M) { @content; } 
  }
  @else if $canvas == L {
   @media only screen and (min-width: $L) { @content; } 
  }
}

@mixin font-smoothing {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------- 

Primary style

-------------------------------- */

*, *::after, *::before {
	box-sizing: border-box;
}

html {
	font-size: 62.5%;
}

body {
	font: {
		size: 1.6rem;
		family: $primary-font; // variables inside partials > _variables.scss
	}
	color: $color-3;
	background-color: $color-2;
	@include font-smoothing;
}

a {
	color: $color-2;
	text-decoration: none;
}

h1,h2 {
	text-align: center;
	width: 90%;
	margin: 2em auto 0;
	
	color: shade($color-2, 50%);
	font-weight: bold;
  a{
    color: shade($color-2, 50%);
  }
	@include MQ(M) {
		font-size: 3.2rem;
	}
}
h1{
  font-size: 2.4rem;
}

h2{
  font-size: 1.4rem;
}
input {
	font-family: $primary-font;
	font-size: 1.6rem;
}

/* -------------------------------- 

Main Components 

-------------------------------- */

.accordion-collection {
	width: 90%;
	max-width: $M;
	background: $color-1;
	margin: 4em auto;
	box-shadow: 0 4px 40px shade($color-2, 30%);
  padding: 0;
  @include transition(transform .3s);
  
	ul {
		/* by default hide all sub menus */
		display: none;
    padding: 0;
	}

	li {
		@include user-select(none);
    list-style: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
	}

	input[type=checkbox] {
		/* hide native checkbox */
		position: absolute;
		opacity: 0;
	}

	label, a {
		position: relative;
		display: block;
		padding: $item-padding-S $item-padding-S $item-padding-S ($item-padding-S * 3) + 10px;
		background: $color-1;
		box-shadow: inset 0 -1px tint($color-1, 5%);
		color: $color-3;
		font-size: 1.6rem;

		.no-touch &:hover {
			background: tint($color-1, 3%);
		}
	}

	label::before, label::after, a::after {
		/* icons */
		content: '';
		display: inline-block;
		width: 16px;
		height: 16px;
		position: absolute;
		top: 50%;
		@include transform(translateY(-50%));
	}

	label {
		cursor: pointer;

		&::before, &::after {
			background-image: url("https://codyhouse.co/demo/multi-level-accordion-menu/img/cd-icons.svg");
			background-repeat: no-repeat;
		}

		&::before {
			/* arrow icon */
			left: $item-padding-S;
			background-position: 0 0;
			@include transform(translateY(-50%) rotate(-90deg));
		}

		&::after {
			/* folder icons */
			left: ($item-padding-S * 2) + 5px;
			background-position: -16px 0;
		}
	}

	a::after {
		/* image icon */
		left: $item-padding-S * 2;
		background: url(https://codyhouse.co/demo/multi-level-accordion-menu/img/cd-icons.svg) no-repeat -48px 0;
	}

	input[type=checkbox]:checked + label::before {
		/* rotate arrow */
		@include transform(translateY(-50%));
	}

	input[type=checkbox]:checked + label::after {
		/* show open folder icon if item is checked */
		background-position: -32px 0;
	}

	input[type=checkbox]:checked + label + ul,
	input[type=checkbox]:checked + label:nth-of-type(n) + ul {
		/* use label:nth-of-type(n) to fix a bug on safari (<= 8.0.8) with multiple adjacent-sibling selectors*/
		/* show children when item is checked */
		display: block;
	}

	ul label,
	ul a {
		background: darken($color-1, 10%);
		box-shadow: inset 0 -1px darken($color-1, 5%);
		padding-left: ($item-padding-S * 4) + 10px;

		.no-touch &:hover {
			background: darken($color-1, 7%);
		}
	}

	> li:last-of-type > label,
	> li:last-of-type > a,
	> li > ul > li:last-of-type label,
	> li > ul > li:last-of-type a {
		box-shadow: none;
	}

	ul label::before {
		left: $item-padding-S * 2;
	}

	ul label::after,
	ul a::after {
		left: ($item-padding-S * 3) + 5px;
	}

	ul ul label,
	ul ul a {
		padding-left: ($item-padding-S * 5) + 10px;
	}

	ul ul label::before {
		left: $item-padding-S * 3;
	}

	ul ul label::after,
	ul ul a::after {
		left: ($item-padding-S * 4) + 5px;
	}

	ul ul ul label,
	ul ul ul a {
		padding-left: ($item-padding-S * 6) + 10px;
	}

	ul ul ul label::before {
		left: $item-padding-S * 4;
	}

	ul ul ul label::after,
	ul ul ul a::after {
		left: ($item-padding-S * 5) + 5px;
	}

	@include MQ(M) {
		label, a {
			padding: $item-padding-M $item-padding-M $item-padding-M ($item-padding-M * 3) + 10px;
			font-size: 1.9rem;
		}

		label::before {
			left: $item-padding-M;
		}

		label::after {
			left: ($item-padding-M * 2) + 5px;
		}

		ul label,
		ul a {
			padding-left: ($item-padding-M * 4) + 10px;
		}

		ul label::before {
			left: $item-padding-M * 2;
		}

		ul label::after,
		ul a::after {
			left: ($item-padding-M * 3) + 5px;
		} 

		ul ul label,
		ul ul a {
			padding-left: ($item-padding-M * 5) + 10px;
		}

		ul ul label::before {
			left: $item-padding-M * 3;
		}

		ul ul label::after,
		ul ul a::after {
			left: ($item-padding-M * 4) + 5px;
		}

		ul ul ul label,
		ul ul ul a {
			padding-left: ($item-padding-M * 6) + 10px;
		}

		ul ul ul label::before {
			left: $item-padding-M * 4;
		}

		ul ul ul label::after,
		ul ul ul a::after {
			left: ($item-padding-M * 5) + 5px;
		}
	}
}

              
            
!

JS

              
                jQuery(document).ready(function(){
	var accordionsMenu = $('.accordion-collection');

	if( accordionsMenu.length > 0 ) {
		
		accordionsMenu.each(function(){
			var accordion = $(this);
			//detect change in the input[type="checkbox"] value
			accordion.on('change', 'input[type="checkbox"]', function(){
				var checkbox = $(this);
				console.log(checkbox.prop('checked'));
				( checkbox.prop('checked') ) ? checkbox.siblings('ul').attr('style', 'display:none;').slideDown(300) : checkbox.siblings('ul').attr('style', 'display:block;').slideUp(300);
			});
		});
	}
});
              
            
!
999px

Console