Pen Settings



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


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


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.


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.


                <button>Open modal</button>
<div class="layer">
	<div class="preloader"></div>
	<div class="modal">
		<div class="modal-content">			
			<div>Lorem ipsum dolor sit amet consectetur adipisicing elit. Deserunt animi voluptates quas non sint est dolor veniam facere eius? Aliquam.</div>			



                * {
	box-sizing: border-box;
$layer_color: #414a52;

html, body {
	height: 100%;
body {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	font-family: sans-serif;
.layer {
	position: fixed;
	top: 0; left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba($layer_color, .8);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	&.active {
		visibility: visible;
		opacity: 1;
.preloader {
	width: 2rem;
	height: 2rem;
	//border-radius: 50%;
	background-color: #fff;
	position: absolute;
	left: 0; right: 0; top: 0; bottom: 0;
	margin: auto;
	opacity: 0; 
	transform: scale(.8);
	//transition: cubic-bezier(1,0,.01,.99) .75s;
	&.animate {
		animation: preloader_animaion .75s infinite;
		animation-fill-mode: both;
@keyframes preloader_animaion {
	0% {opacity: .5; transform: scale(.8)}
	50% {opacity: 1; transform: scale(1.2) rotate(180deg)}
	100% {opacity: .5; transform: scale(.8) rotate(0)}
.modal {
	background: #fff;
	width: 400px;
	height: 400px;
	margin-bottom: 2rem;
	box-shadow: 0 0 60px -5px rgba(0,0,0,.3);
	overflow: hidden;
	transform: scale(0);
	&-content {
		padding: 2rem;
		opacity: 0;


                let button = document.querySelector('button'),
	layer = document.querySelector('.layer'),
	modal = document.querySelector('.modal'),
	content = modal.querySelector('.modal-content'),
	preloader = document.querySelector('.preloader'),
	clickTargets = [layer, button],
	tl = new TimelineMax({
		paused: true,
		reversed: true

let openAnimation = () => {
	const tl = new TimelineLite();, .5, {autoAlpha: 1, opacity: 1})	
	.set(preloader, {className: '+=animate'})
	.to(modal, .3, { scale: 1, ease: Back.easeOut}, "+=1.1")
	.to(content, .3, {opacity: 1, ease: Sine.easeOut})
	return tl;

let closeAnimation = () => {
	const tl = new TimelineLite();
	tl.set(preloader, {className: '-=animate'})
	.to(content, .3, {opacity: 0, ease: Sine.easeOut})
	.to(modal, .3, {scale: 0, ease: Sine.easeOut})
	.to(layer, .5, {autoAlpha: 0})		
	return tl;

var isOpen = false;

clickTargets.forEach(target => {
	target.addEventListener('click', () => {
		} else {
		isOpen = !isOpen
modal.addEventListener('click', (e) => {