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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 id="park"></div>
<div id="filters" class="cf">
	<div class="filterbox"></div>
	<ul class="navi"><li><a class="prev">PREV</a></li><li><a class="next">NEXT</a></li></ul>
</div>


<section id="template">

<div class="animal">
	<div class="pic"></div>
	<p  class="name">Sample</p>
	<dl class="info">
		<dt>Sort : </dt><dd class="sort">sample</dd>
		<dt>Food : </dt><dd class="food">sample</dd>
		<dt>Sex  : </dt><dd class="sex" >sample</dd>
		<dt>Age  : </dt><dd class="age" >sample</dd>
		<dt>From : </dt><dd class="from">sample</dd>
		<dt>Mind : </dt><dd class="mind">sample</dd>
	</dl>
</div>

<section class="filter cf">
	<h1 class="ttl">SAMPLE</h1>
	<ul class="options">
		<li class="option"><a>Sample</a></li>
	</ul>
</section>


</section>
              
            
!

CSS

              
                /* -------------------------------------------------------------- */
/* RESET */
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600,700);
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, dialog, figure, footer, header, hgroup, menu, nav, section, menu, time, mark, audio, video { margin:0; padding:0; border:0; outline:0; font-size:100%; vertical-align:baseline; background-color:transparent; }
.cf:before, .cf:after { content: " "; display: table; }
.cf:after { clear: both; }
.cf { *zoom: 1; }


/* -------------------------------------------------------------- */
/* Common */

html,body{ width:100%; height:100%; }

body{
	position: relative;
	margin: 0;
	padding: 0;
	background-color: #191919;
	font-family:'Source Code Pro', 'Droid Sans Mono';
	user-select: none;
	-moz-user-select: none;
	-webkit-user-select: none;
	-ms-user-select: none;
}


/* -------------------------------------------------------------- */
/* Common */

#park{
	display: block;
	width: 100%;
	margin: 0 0 -15px 0;
	padding: 80px 0 60px 0;
	text-align: center;
}

#template{
	display: none;
}


/* -------------------------------------------------------------- */
/* Animal */

.animal{
	display: inline-block;
	width: 200px;
	padding: 0 10px 15px 10px;
	text-align: left;
}
.animal .pic{
	width: 150px;
	height: 150px;
	margin: 25px;
	background:url(https://dl.dropboxusercontent.com/u/10162000/codepen/zoo/animals.svg);
	background-color: #252525;
	background-repeat: no-repeat;
	background-size: auto 150px;
	-webkit-transform: rotateY(180deg);
	-webkit-transition: all 1200ms cubic-bezier(0.230, 1.000, 0.320, 1.000);
}
.animal .name{
	display: block;
	border-top: solid 1px #222222;
	padding: 18px 0 12px 0;
	color: #AAA;
	font-size: 14px;
	letter-spacing: 1px;
	line-height: normal;
}
.animal .info{
	display: block;
	width: 100%;
	color: #444;
	font-size: 11px;
	-webkit-transition: all 350ms;
}
.animal .info dt{
	width: 25%;
	display: inline-block;
	text-transform: uppercase;
}
.animal .info dd{
	width: 75%;
	display: inline-block;
}

.animal.on{}
.animal.on .info{ color: #555; }
.animal.on .pic { -webkit-transform: rotateY(-180deg); }
.animal.on.male   .pic{  background-color: #5DD0D0; }
.animal.on.female .pic{  background-color: #DF88B3; }
.animal:hover .info{ color: #777; }

.animal.gorilla .pic{ background-position: 0 0; }
.animal.giraffe .pic{ background-position: -150px 0; }
.animal.fox 	.pic{ background-position: -300px 0; }
.animal.horse 	.pic{ background-position: -450px 0; }
.animal.tiger 	.pic{ background-position: -600px 0; }
.animal.rhino 	.pic{ background-position: -750px 0; }
.animal.bear 	.pic{ background-position: -900px 0; }
.animal.flamingo .pic{ background-position: -1050px 0; }


/* -------------------------------------------------------------- */
/* Filters */

#filters{
	position: fixed;
	/*bottom: 0;*/
	top: 0;
	display: block;
	width : 100%;
	height: 50px;
	background-color: #202020;
	overflow: hidden;
}

#filters .filterbox{
	width : 80%;
	height: 50px;
	padding-top: 17px;
	float: left;
	-webkit-transition: all 600ms cubic-bezier(0.230, 1.000, 0.320, 1.000);
}

#filters .filter{
	display: block;
	height: 50px;
	font-size: 12px;
}

#filters .filter .ttl{
	display: block;
	float: left;
	padding: 0 20px 0 35px;
	color: #CCC;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
}

#filters .options{
	display: block;
	float: left;
}

#filters .options li{
	display: inline-block;
	padding-right: 12px;
}

#filters .options li a{
	position: relative;
	cursor: pointer;
	color: #666;
	font-size: 12px;
	font-weight: 600;
	vertical-align: top;
	text-transform: uppercase;
	-webkit-transition: all 350ms;
}

#filters .options li a:before{
	content: "";
	display: inline-block;
	width: 0.9em;
	height: 0.9em;
	border: solid 1px #444;
	background-color: #333;
	box-sizing: border-box;
	margin-right: 4px; 
}

#filters .options li a:hover{ color: #DDD; }
#filters .options li a.on{ color: #DDD; }
#filters .options li a.on:before{
	background-color: #DDD;
	border-color: #EEE;
}


/* -------------------------------------------------------------- */
/* Filters Navi */

#filters .navi{
	width : 20%;
	float: right;
	padding-top: 17px;
	font-size: 12px;
	text-align: right;
}

#filters .navi li{
	display: inline-block;
	padding-right: 25px;
}

#filters .navi li a{
	display: block;
	cursor: pointer;
	color: #CCC;
	letter-spacing: 1px;
	font-weight: 700;
	-webkit-transition: all 350ms;
}

#filters .navi li a:hover{ color: #33CC88; }
              
            
!

JS

              
                

var SUM = 100;
var db;
var data;
var fcnt;
var flen;
var flist;
var $park;
var $fbox;
var $tmpl_animal;
var $tmpl_filter;

init();


function init(){

	$park = $('#park');
	$fbox = $('#filters .filterbox');
	$tmpl_animal = $('#template .animal');
	$tmpl_filter = $('#template .filter');
	$('.prev').click(onPrevClick);
	$('.next').click(onNextClick);

	db = new AnimalData();
	data = db.get(SUM);
	makePark();
	makeFilters();
}

function makePark(){

	var keys = ['name', 'sort', 'food', 'sex', 'age', 'from', 'mind'];
	
	for(var i=0; i<SUM; i++){
		var $animal = $tmpl_animal.clone();
		var mydata = data[i];
		for(var j=0, len=keys.length; j<len; j++){
			var key = keys[j];
			var val = mydata[key] + '';
			var cname = val.toLowerCase();
			$animal.find('.'+key).html(val);
			if(key!='name' || key!='age') $animal.addClass(cname);
		}
		$animal.appendTo($park);
	}
}


function makeFilters(){

	var keys = ['sort', 'food', 'sex', 'from', 'mind'];
	var $tmpl_option = $tmpl_filter.find('.option').eq(0);

	fcnt = 0;
	flen = keys.length;
	flist = [];

	for(var i=0; i<flen; i++){
		var key = keys[i];
		var arr = db.getList(key);
		var $filter = $tmpl_filter.clone();
		var $options = $filter.find('.options');
		$options.empty();
		for(var j=0; j<arr.length; j++){
			$tmpl_option
			.clone()
			.appendTo($options)
			.find('a')
			.html(arr[j])
			.click(onOptionClick);
		}
		$filter.appendTo($fbox).find('.ttl').html(key);
	}
}


function applyFilter(){
	var selector = flist.join(', .');
	if(flist.length!=0) selector = '.' + selector;
	$park.find('.animal').removeClass('on');
	$park.find(selector).addClass('on');
}


function addFilter(_cname){
	var cname = _cname;
	var exist = $.inArray(cname, flist);
	if(exist==-1) flist.push(cname);
}


function removeFilter(_cname){
	var cname = _cname;
	var exist = $.inArray(cname, flist);
	if(exist!=-1) flist.splice(exist, 1);
}


function resetFilter(){
  flist = [];
  applyFilter();
}


function onOptionClick(_e){
	var $self = $(this);
	var cname = $self.text().toLowerCase();
	$self.toggleClass('on');
	if($self.hasClass('on')){
		addFilter(cname);
	}else{
		removeFilter(cname);
	}
	applyFilter();
}


function onPrevClick(_e){
	fcnt = (fcnt-1+flen)%flen;
	$fbox.css('margin-top', (-50*fcnt)+"px");
  resetFilter();
}


function onNextClick(_e){
	fcnt = (fcnt+1)%flen;
	$fbox.css('margin-top', (-50*fcnt)+"px");
  resetFilter();
}



              
            
!
999px

Console