123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              - var avengers = [{ name: "Ant-Man", alterego: 'Scott Lang', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/antman.png'},{ name: "Black Panther", alterego: "T'Challa", snap: "true", image: 'https://olivia-ng.com/codepen/avengers/blackp.png'},{ name: "Black Widow", alterego: 'Natasha Romanoff', snap: "false", image: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/567707/blackwidow2.png'},{ name: "Captain America", alterego: 'Steve Rogers', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/cap.png'},{ name: 'Captain Marvel', alterego:'Carol Danvers',snap: "false", image: 'https://olivia-ng.com/codepen/avengers/marvel.png'},{name: "Doctor Strange", alterego:'Stephen Strange', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/strange.png'},{ name: "Drax", alterego: 'Arthur Douglas', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/drax.png'},{ name: "Falcon", alterego: 'Sam Wilson', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/falcon.png'},{ name: 'Nick Fury', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/fury.png'},{ name: 'Groot', snap: "true", alterego:"Flora Colossus", image: 'https://olivia-ng.com/codepen/avengers/groot.png'},{ name: 'Hawkeye', snap: "false", alterego:'Clint Barton',image: 'https://olivia-ng.com/codepen/avengers/hawkeye.png'},{ name: 'Hulk', snap: "false", alterego: 'Bruce Banner',image: 'https://olivia-ng.com/codepen/avengers/hulk.png'},{ name: 'Iron Man', alterego:'Tony Stark',snap: "false", image: 'https://olivia-ng.com/codepen/avengers/ironman.png'},{ name: 'Mantis', alterego:'Brandt',snap: "true", image: 'https://olivia-ng.com/codepen/avengers/mantis.png'},{ name: 'Maria Hill', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/maria.png'},{ name: 'Nebula', snap: "false", alterego:'Luphomoid', image: 'https://olivia-ng.com/codepen/avengers/nebula.png'},{ name: 'Okoye', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/okoye.png'},{ name: "Rocket Raccoon",  snap: "false", image: 'https://olivia-ng.com/codepen/avengers/rockt.png'}, {name: "Scarlet Witch", alterego: 'Wanda Maximoff', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/scarlet.png'},{name: "Shuri", snap: "true", image: 'https://olivia-ng.com/codepen/avengers/shuri.png'},{name: "Spider-Man", alterego:'Peter Parker', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/spidey.png'},{name: "Star-Lord", alterego:'Peter Quill', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/starlord.png'},{ name: "Thor", alterego: 'Thor Odinson', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/thor.png'},{ name: "Valkyrie", alterego: 'Brunnhilde', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/valkyrie.png'},{ name: "War Machine", alterego: 'James Rhodes', snap: "false", image: 'https://olivia-ng.com/codepen/avengers/rhodes.png'},{ name: "Wasp", alterego: '	Janet Van Dyne', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/wasp.png'},{ name: "Winter Soldier", alterego: 'Bucky Barnes', snap: "true", image: 'https://olivia-ng.com/codepen/avengers/bucky.png'},{ name: "Wong", snap: "false", image: 'https://olivia-ng.com/codepen/avengers/wong.png'}]

.overlay

main.main-content.showall
	each val in avengers
		.profile(data-snap=val.snap)
			.profile__image
				img(src=val.image)
			.profile__name 
				h5.main= val.name
				p.alter-ego= val.alterego
		
aside.snap-area
	.snap-area__controls
		.snap-area__controls__radio
			span Unsnap
			input#snap.toggle(type="checkbox")
			label.toggle(for="snap")
			span Snap
		.snap-area__controls__check
			input#show.show-all(type="checkbox" checked)
			label.show-all(for="show") Show All Characters
		
		
	.snap-area__image
		img(src="https://olivia-ng.com/codepen/avengers/thanos.png" alt="Thanos")

            
          
!
            
              
body {
  background: #222;
  font-family: 'Comfortaa', sans-serif;
	text-shadow: 0 3px 4px rgba(0,0,0,0.5);
	color: #fff;
}

* {
	box-sizing: border-box;
}

main.main-content {
	margin-top: 80px;
	padding: 40px;
	display: grid;
	justify-content: center;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	grid-gap: 20px;
	position: relative;
}

.overlay {
	width: 100%;
	height: 100%;
	position: absolute;
	background: #000;
	top: 0;
	left: 0;
	z-index: 0;
	opacity: 0;
}

.profile {
	position: relative;
	overflow: hidden;
	&__image {
		background: url('https://olivia-ng.com/codepen/avengers/background.png') no-repeat left top / cover;
		padding-top: 20px;
		height: 325px;
		img {
			height: 90%;
			width: 100%;
			object-fit: contain;
			position: absolute;
			bottom: 0;
		}
	}
	&__name {
		
		position: absolute;
		width: 90%;
		bottom: 20px;
		left: 20px;
		.main {
			font: 900 30px/1.1 'Playfair Display', serif;
		}
		.alter-ego {
			margin-top: 5px;
			font: 400 18px/1 'Playfair Display', serif;
		}
	}
}

.snap-area {
	position: fixed;
	width: 100%;
	height: 80px;
	top: 0;
	background: linear-gradient(to bottom right, rgb(15, 12, 41), rgb(48, 43, 99), rgb(36, 36, 62));
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: space-around;
	&__controls {
		display: flex;
		font: 24px "Bangers";
		letter-spacing: 1px;
		align-items: center;
		justify-content: space-around;
		z-index: 10;
		position: relative;
	}
	&__controls__radio {
		position: relative;
		z-index: 2;
		display: flex;
		align-items: center;
		margin-right: 50px;
	}
	&__image {
		text-align: right;
		position: absolute;
		right: 0;
		top: -25px;
		user-select: none; 
	}
	img {
		opacity: 0.4;
		max-width: 250px;
	}
}

input.toggle {
	display: none;
}

label.toggle {
	outline: 0;
	display: block;
	width: 1.6em;
	height: 8px;
	background: rgba(255,255,255,0.4);
	position: relative;
	cursor: pointer;
	border-radius: 2em;
	padding: 2px;
	transition: all .4s ease;
	margin: .8em;
	&:after {
		position: relative;
    display: block;
    content: "";
    width: 18px;
    height: 18px;
		border-radius: 50%;
    background: #fff;
    transition: all .2s ease;
		border: 1px solid rgb(15, 12, 41);
		left: -2px;
		top: -8px;
	}
}

input.toggle:checked + label.toggle {
	background: rgba(255,255,255,0.9);
	&:after {
		left: 52%;
	}
}


input.show-all {
	display: none;
}

label.show-all {
	padding-left: 30px;
	position: relative;
	display: inline-block;
	cursor: pointer;
	&:before {
		content: '';
		position: absolute;
		top: 2px;
		left: 0;
    display: inline-block;
    width: 20px;
    height: 20px;
		border-radius: 3px;
    background: #fff;
    transition: all .2s ease;
		border: 1px solid rgb(15, 12, 41);
		background: rgba(255,255,255,0.6);
	}
	&:after {
    content: "";
		position: absolute;
		color: rgb(15, 12, 41);
		font-size: 18px;
    transition: all .2s ease;
		left: 4px;
		top: 0px;
		text-shadow: none;
	}
}


input.show-all:checked + label.show-all {
	&:after {
		content: "✔";
	}
}

.snapped {
	.profile[data-snap="true"] {
		display: none;
	}
	&.showall .profile[data-snap="true"] {
		display: block;
		filter: grayscale(1);
		opacity: 0.8;
	}
}

@keyframes flash {
	0% { opacity: 0; z-index: 20; }
	5%, 40% { opacity: 1; z-index: 20; }
}

.overlay.flash {
	animation: 1s flash;
}
            
          
!
            
              var audio = new Audio('https://olivia-ng.com/codepen/avengers/fingersnap.mp3');

$('label.toggle').on('click',function(){
	audio.play();
	$('.overlay').addClass('flash');
	setTimeout(function(){
		$('.main-content').toggleClass('snapped');
	}, 200);
	setTimeout(function(){
		$('.overlay').removeClass('flash');
	}, 1000);
	
});

$('label.show-all').on('click',function(){
	$('.main-content').toggleClass('showall');
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console