Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                - var usStateList = [{"name":"Alabama","abbr":"al","checked": true},{"name":"Alaska","abbr":"ak","checked": false},{"name":"Arizona","abbr":"az","checked": true},{"name":"Arkansas","abbr":"ar","checked": false},{"name":"California","abbr":"ca","checked": true},{"name":"Colorado","abbr":"co","checked": true},{"name":"Connecticut","abbr":"ct","checked": true},{"name":"Delaware","abbr":"de","checked": false},{"name":"District of Columbia","abbr":"dc","checked": true},{"name":"Florida","abbr":"fl","checked": true},{"name":"Georgia","abbr":"ga","checked": true},{"name":"Hawaii","abbr":"hi","checked": true},{"name":"Idaho","abbr":"id","checked": false},{"name":"Illinois","abbr":"il","checked": true},{"name":"Indiana","abbr":"in","checked": false},{"name":"Iowa","abbr":"ia","checked": true},{"name":"Kansas","abbr":"ks","checked": false},{"name":"Kentucky","abbr":"ky","checked": false},{"name":"Louisiana","abbr":"la","checked": false},{"name":"Maine","abbr":"me","checked": true},{"name":"Maryland","abbr":"md","checked": false},{"name":"Massachusetts","abbr":"ma","checked": true},{"name":"Michigan","abbr":"mi","checked": true},{"name":"Minnesota","abbr":"mn","checked": false},{"name":"Mississippi","abbr":"ms","checked": true},{"name":"Missouri","abbr":"mo","checked": false},{"name":"Montana","abbr":"mt","checked": true},{"name":"Nebraska","abbr":"ne","checked": true},{"name":"Nevada","abbr":"nv","checked": true},{"name":"New Hampshire","abbr":"nh","checked": false},{"name":"New Jersey","abbr":"nj","checked": true},{"name":"New Mexico","abbr":"nm","checked": true},{"name":"New York","abbr":"ny","checked": true},{"name":"North Carolina","abbr":"nc","checked": true},{"name":"North Dakota","abbr":"nd","checked": false},{"name":"Ohio","abbr":"oh","checked": true},{"name":"Oklahoma","abbr":"ok","checked": false},{"name":"Oregon","abbr":"or","checked": false},{"name":"Pennsylvania","abbr":"pa","checked": false},{"name":"Rhode Island","abbr":"ri","checked": true},{"name":"South Carolina","abbr":"sc","checked": false},{"name":"South Dakota","abbr":"sd","checked": true},{"name":"Tennessee","abbr":"tn","checked": false},{"name":"Texas","abbr":"tx","checked": true},{"name":"Utah","abbr":"ut","checked": true},{"name":"Vermont","abbr":"vt","checked": true},{"name":"Virginia","abbr":"va","checked": true},{"name":"Washington","abbr":"wa","checked": false},{"name":"West Virginia","abbr":"wv","checked": true},{"name":"Wisconsin","abbr":"wi","checked": true},{"name":"Wyoming","abbr":"wy","checked": true}];

mixin stateTile(state)
 input(type="checkbox", id=state.abbr, checked=state.checked)
 label(for=state.abbr, title=state.name)
  span.state__name= state.name
  span.state__abbr= state.abbr

ul(id="usStates", class="mode--map")
 each state, i in usStateList
  li(class="state state--" + (i+1) + " state--" + (state.abbr))
   +stateTile(state)
	 
form(class='toggle')
 input(type='radio' name='type' value='type-0' id='type-0' checked)
 label(for='type-0')
  span= 'Auto'
 input(type='radio' name='type' value='type-1' id='type-1')
 label(for='type-1')
  span= 'Map'
 input(type='radio' name='type' value='type-2' id='type-2')
 label(for='type-2')
  span= 'Tiles'
 input(type='radio' name='type' value='type-3' id='type-3')
 label(for='type-3')
  span= 'List'
              
            
!

CSS

              
                body{
	height: 100vh;
	margin: 0;
	font-family: Cousine;
	background-image: radial-gradient(circle, #0050c9, #0044c3, #0037bc, #0029b5, #0118ad);
	color: rgba(255,255,255,.45);
	font-size: 16px;
	display: grid;
	grid-template-rows: 1fr 100px;
	grid-template-columns: 1fr;
	align-items: center;
	align-content: center;
	justify-content: center;
	overflow: hidden;
}

.state {
	transition: all 200ms ease-in;
	&__abbr {
		text-transform: uppercase; 
	}
}

.mode {
	&--list {
		column-count: 3;
		column-gap: 50px;
		max-width: 1000px;
		list-style: none;
		margin: 0 auto;
		.state__abbr {
			display: none;
		}
		li:nth-child(odd) {
			animation: slideFromLeft 300ms ease-in;
		}
		li:nth-child(even) {
			animation: slideFromRight 300ms ease-in;
		}
		input {
			&:checked {
				+ label,
				+ label:hover{
					color: #ffffff;
					font-weight: 700;

				}
			}
			+ label {
				transition: all 200ms ease-in;
				&:hover {
					color: rgba(255,255,255,.7);
				}
			}
		}
	}
	&--map {
		grid-template-columns: repeat(11, 50px);
		grid-template-rows: repeat(8, 50px);
	}
	&--tile {
		grid-template-columns: repeat(11, 50px);
		grid-template-rows: repeat(5, 50px);
	}
	&--tile,
	&--map{
		display: grid;
		align-content: center;
		justify-content: center;
		grid-gap: 3px;
		list-style: none;
		input {
			display: none;
			&:checked {
				+ label {
					background-color: rgba(255,255,255,1);
					color: #000000;
					font-weight: 700;
				}
			}
			+ label {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				transition: all 200ms ease-in;
				cursor: pointer;
			}
		}
		.state {
			display: flex;
			align-content: center;
			justify-content: center;
			background-color: rgba(0,0,0,.5);
			transition: all ease-in-out 200ms;
			&__name {
				display: none;
			}
			&:hover{
				// transform: scale(1.15);
				background-color: rgba(0,0,0,.8);
			}
		}
	}
	&--map{
		.state {
			&--ak {
				order: 0;
			}
			&--me {
				order: 1;
				grid-column: 11;
			}
			&--vt {
				order: 2;
				grid-column: 10;
			}
			&--nh {
				order: 3;
			}
			&--wa {
				order: 4;
			}
			&--id {
				order: 5;
			}
			&--mt {
				order: 6;
			}
			&--nd {
				order: 7;
			}
			&--mn {
				order: 8;
			}
			&--mi {
				order: 9;
				grid-column: 7;
			}
			&--ny {
				order: 10;
				grid-column: 9;
			}
			&--ma {
				order: 11;
			}
			&--ri {
				order: 12;
			}
			&--or {
				order: 13;
			}
			&--ut {
				order: 14;
			}
			&--wy {
				order: 15;
			}
			&--sd {
				order: 16;
			}
			&--ia {
				order: 17;
			}
			&--wi {
				order: 18;
			}
			&--in {
				order: 19;
			}				
			&--min {
				order: 20;
			}
			&--oh {
				order: 21;
			}
			&--pa {
				order: 22;
			}
			&--nj {
				order: 23;
			}
			&--ct {
				order: 24;
			}			
			&--ca {
				order: 25;
			}			
			&--nv {
				order: 26;
			}			
			&--co {
				order: 27;
			}			
			&--ne {
				order: 28;
			}			
			&--mo {
				order: 29;
			}	
			&--il {
				order: 30;
			}	
			&--ky {
				order: 31;
			}	
			&--wv {
				order: 32;
			}	
			&--md {
				order: 33;
			}	
			&--de {
				order: 34;
			}	
			&--de {
				order: 35;
			}	
			&--az {
				order: 36;
				grid-column: 2;
			}
			&--nm {
				order: 37;
			}	
			&--ks {
				order: 38;
			}	
			&--ar {
				order: 39;
			}	
			&--tn {
				order: 40;
			}	
			&--nc {
				order: 41;
			}	
			&--sc {
				order: 42;
			}	
			&--va {
				order: 43;
			}	
			&--dc {
				order: 44;
			}					
			&--ok {
				order: 45;
				grid-column: 4;
			}
			&--la {
				order: 46;
			}
			&--ms {
				order: 47;
			}
			&--al {
				order: 48;
			}
			&--ga {
				order: 49;
			}
			&--hi {
				order: 50;
				grid-column: 1;
			}
			&--tx {
				order: 51;
				grid-column: 4;
			}
			&--fl {
				order: 52;
				grid-column: 8;
			}	
		}
	}
}

.toggle {
	text-align: center;
	input{
	display: none;
		&:checked + label,
		&:checked + label:hover {
			background: rgba(255,255,255,1);	
			color: #000000;
		}
		+ label{
			background: rgba(0,0,0,.1);
			padding: 10px;
			transition: all 200ms ease-in;
			&:hover {
				background: rgba(0,0,0,.3);
			}
		}
	}
}

@keyframes slideFromRight {
	0% {
		transform: translateX(100px);
		opacity: 0;
	}
	100% {
		transform: translateX(0px);
		opacity: 1;
	}
}
@keyframes slideFromLeft{
	0% {
		transform: translateX(-100px);
		opacity: 0;
	}
	100% {
		transform: translateX(0px);
		opacity: 1;
	}
}
              
            
!

JS

              
                //All JS is for the swapping between modes
function autoPlay(){
    var timer, i=1;
    timer = setInterval(function(){
			//Don't run if any other Modes are selected
			if($("input[type=radio]:checked").val() != "type-0"){  
				return;
			}
			//Reset increment to 1 once max Modes is reached
			if (i > 3) i = 1;
			//Mode Swapping
			if (i == 1) {
				$("#usStates").removeClass().addClass("mode--map");
			} else if (i == 2) {
				$("#usStates").removeClass().addClass("mode--tile");
			} else if (i == 3) {
				$("#usStates").removeClass().addClass("mode--list");
			}
			i++;
    }, 2000);
};

autoPlay();

$('input[type=radio]').change(function() {     
		if($(this).val() == "type-0"){   
	    autoPlay();
    }
		else if($(this).val() == "type-1"){   
	    $("#usStates").removeClass().width();
			$("#usStates").addClass('mode--map');
    }
    else if($(this).val() == "type-2"){
			$("#usStates").removeClass().width();
			$("#usStates").addClass('mode--tile');
    }
		else if($(this).val() == "type-3"){
			$("#usStates").removeClass().width();
			$("#usStates").addClass('mode--list');
    }
});
              
            
!
999px

Console