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 class="wrapper">

	<ul id="index" data-level="1" data-color="white">
		<li class="blue" data-link="#section-1">1</li>
		<li class="green" data-link="#section-2">2</li>
		<li class="yellow" data-link="#section-3">3</li>
	</ul>

		<ul id="section-1" data-level="2" data-color="blue">
			<li data-link="#section-1-1">1.1</li>
			<li data-link="#section-1-1">1.2</li>
			<li data-link="#section-1-1">1.3</li>
			<li data-link="#section-1-1">1.4</li>
			<li data-link="#section-1-1">1.5</li>
			<li data-link="#section-1-1">1.6</li>
			<li data-link="#section-1-1">1.7</li>
			<li data-link="#section-1-1">1.8</li>
			<li data-link="#section-1-1">1.9</li>
			<li data-link="#section-1-1">1.10</li>
			<li data-link="#section-1-1">1.11</li>
			<li data-link="#section-1-1">1.12</li>
			<li data-link="#section-1-1">1.13</li>
			<li data-link="#section-1-1">1.14</li>
			<li class="back" data-link="#index">back</li>
		</ul>

			<ul id="section-1-1" data-level="3" data-color="white">
				<li class="content blue">1.1 - 1.14 content</li>
				<li class="back" data-link="#section-1">back</li>
			</ul>

		<ul id="section-2" data-level="2" data-color="green">
			<li data-link="#section-2-1">2.1</li>
			<li data-link="#section-2-2">2.2</li>
			<li data-link="#section-2-3">2.3</li>
			<li class="back" data-link="#index">back</li>
		</ul>

			<ul id="section-2-1" data-level="3" data-color="white">
				<li class="content green">2.1 content</li>
				<li class="back" data-link="#section-2">back</li>
			</ul>

			<ul id="section-2-2" data-level="3" data-color="white">
				<li class="content green">2.2 content</li>
				<li class="back" data-link="#section-2">back</li>
			</ul>

			<ul id="section-2-3" data-level="3" data-color="white">
				<li class="content green">2.3 content</li>
				<li class="back" data-link="#section-2">back</li>
			</ul>

		<ul id="section-3" data-level="2" data-color="yellow">
			<li class="orange" data-link="#section-3-1">3.1</li>
			<li class="red" data-link="#section-3-2">3.2</li>
			<li class="pink" data-link="#section-3-3">3.3</li>
			<li class="violet" data-link="#section-3-4">3.4</li>
			<li class="back" data-link="#index">back</li>
		</ul>

			<ul id="section-3-1" data-level="3" data-color="orange">
				<li data-link="#section-3-1-1">3.1.1</li>
				<li data-link="#section-3-1-1">3.1.2</li>
				<li data-link="#section-3-1-1">3.1.3</li>
				<li class="back" data-link="#section-3">back</li>
			</ul>

				<ul id="section-3-1-1" data-level="4" data-color="white">
					<li class="content orange">3.1.1 - 3.1.3 content</li>
					<li class="back" data-link="#section-3-1">back</li>
				</ul>

			<ul id="section-3-2" data-level="3" data-color="red">
				<li class="content white">3.2 content</li>
				<li class="back" data-link="#section-3">back</li>
			</ul>

			<ul id="section-3-3" data-level="3" data-color="pink">
				<li data-link="#section-3-3-1">3.3.1</li>
				<li data-link="#section-3-3-2">3.3.2</li>
				<li data-link="#section-3-3-3">3.3.3</li>
				<li data-link="#section-3-3-4">3.3.4</li>
				<li class="back" data-link="#section-3">back</li>
			</ul>

				<ul id="section-3-3-1" data-level="4" data-color="white">
					<li class="content pink">3.3.1 content</li>
					<li class="back" data-link="#section-3-3">back</li>
				</ul>

				<ul id="section-3-3-2" data-level="4" data-color="white">
					<li class="content pink">3.3.2 content</li>
					<li class="back" data-link="#section-3-3">back</li>
				</ul>

				<ul id="section-3-3-3" data-level="4" data-color="white">
					<li class="content pink">3.3.3 content</li>
					<li class="back" data-link="#section-3-3">back</li>
				</ul>

				<ul id="section-3-3-4" data-level="4" data-color="white">
					<li class="content pink">3.3.4 content</li>
					<li class="back" data-link="#section-3-3">back</li>
				</ul>

			<ul id="section-3-4" data-level="3" data-color="violet">
				<li class="content white">3.4 content</li>
				<li class="back" data-link="#section-3">back</li>
			</ul>

</div>
            
          
!
            
              
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,700);

body {
	margin: 50px;
	padding: 0;
	background: #fff;
	color: #000;
	font-family: 'Roboto Slab', serif;
	font-weight: 700;
	font-size: 32px;
	line-height: 32px;
	text-transform: uppercase;
}

.wrapper {
	position: relative;
	display: inline-block;
}

ul {
	display: inline-block;
	margin: 0;
	padding: 0;
	list-style-type: none;
	max-width: 1100px;
}

li {
	display: block;
	box-sizing: border-box;
	float: left;
	width: 200px;
	height: 200px;
	padding: 20px;
	margin: 10px;
	background: #fff;
	cursor: pointer;
	overflow: hidden;
}

p {
	font-size: 16px;
	font-weight: 400;
	line-height: 18px;
}

.content {
	width: 640px;
	height: 420px;
	cursor: default;
}

.back {
	background: none;
}

.hidden {
	display: none;
}

.no-overflow {
	overflow: hidden;
}

.white {
	background: #fff;
}

.red {
	background: #e3181a;
}

.orange {
	background: #f4a400;
}

.yellow {
	background: #f2ea00;
}

.green {
	background: #9fca2d;
}

.cyan {
	background: #7cc6a4;
}

.blue {
	background: #58b9ec;
}

.violet {
	background: #8551a2;
}

.pink {
	background: #e2137a;
}

            
          
!
            
              $(document).ready(function(){

	// hide all except for the base group
	$('ul').each(function(){
		if($(this).attr('data-level')>1){
			$(this).addClass('hidden');
		}
	});

	//vars
	var currentgroup;
	var selectedgroup;
	var colorgroup;
	var xy = [];
	var sc = [];

	// box actions
	$('li').on('click', function(){

		// don't do anything if no data-link provided
		if($(this).attr('data-link') == null){
			return false;
		}

		currentgroup = $(this).parent();
		selectedgroup = $($(this).attr('data-link'));
		colorgroup = selectedgroup.attr('data-color');
		xy[currentgroup.attr('data-level')] = ($(this).position().left + $(this).outerWidth(true)/2) + 'px ' + ($(this).position().top + $(this).outerHeight(true)/2) + 'px'; // center of the box in an array for proper transform-origins for each level clicked
		sc[currentgroup.attr('data-level')] = $(window).scrollTop(); // scroll position for each level, used for the back button

		$('body').addClass('no-overflow');

		if(!$(this).hasClass('back')) {

			// going forward
			$('.wrapper')
				.css({'transform-origin': xy[currentgroup.attr('data-level')]})
				.animate({'transform': 'scale(25, 25)'}, 500, 'Power4.easeIn', function (){
					currentgroup.addClass('hidden');
					selectedgroup.removeClass('hidden');					
					$('body')
						.attr('class', 'no-overflow ' + colorgroup)
						.animate({'scrollTop': '0px'}, 500, 'Power4.easeOut');
					$('.wrapper')
						.animate({'transform': 'scale(0, 0)'}, 0)
						.animate({'transform': 'scale(1, 1)'}, 500, 'Power4.easeOut', function(){
							$('body').removeClass('no-overflow');
						});
				});

		} else {

			// and backwards
			$('.wrapper')
				.css({'transform-origin': xy[currentgroup.attr('data-level')-1]})
				.animate({'transform': 'scale(0, 0)'}, 600, 'Power4.easeIn', function (){
					currentgroup.addClass('hidden');
					selectedgroup.removeClass('hidden');
					$('body')
						.attr('class', 'no-overflow ' + colorgroup)
						.animate({'scrollTop': sc[currentgroup.attr('data-level')-1]}, 500, 'Power4.easeOut');
					$('.wrapper')
						.animate({'transform': 'scale(25, 25)'}, 0)
						.animate({'transform': 'scale(1, 1)'}, 500, 'Power4.easeOut', function(){ 
							$('body').removeClass('no-overflow');
						});
				});

		}
		
	});

	// fill in content boxes with some random text
	var cnt = [
		'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
		'Suspendisse sollicitudin vel nibh id vestibulum',
		'Maecenas gravida felis in ante hendrerit molestie',
		'Mauris quis tortor neque',
		'Aliquam erat volutpat',
		'Nulla hendrerit egestas metus id dictum',
		'Nunc cursus dolor enim, et molestie eros sagittis sit amet',
		'Sed pretium felis ut erat hendrerit eget venenatis libero euismod',
		'Fusce quis lorem risus',
		'Mauris mattis mauris sit amet neque laoreet malesuada',
		'Praesent at lectus sapien',
		'Quisque eget augue mauris'];

	$('li:not(.back)').each(function(){
		$(this).append('<p>'+ cnt[Math.floor(Math.random()*cnt.length)] +'</p>');
	});

});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console