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 n = 2;

input(type='checkbox' id='pause')
label(for='pause') pause animation

section
	.rect

pre
	while n--
		- var c2 = n ? '#fff' : 'transparent';
		span.token--grad(style=`--i: ${n}`)
			span.token--func repeating-linear-gradient
			span.token--punc (
			span.token--args
				span.token--arg
					span.token--ang
						span.token--num #{Math.pow(-1, n + 1)*60}
						span.token--unit deg
				span.token--punc ,
				|  
				span.token--arg
					span.token--stop
						span.token--col #000
						|  
						span.token--pos 0
				span.token--punc ,
				|  
				span.token--arg
					span.token--stop
						span.token--col #000
						|  
						span.token--pos
							span.token--num 5
							span.token--unit px
				span.token--punc ,
				|  
				span.token--arg
					span.token--stop
						span.token--col #{c2}
						|  
						span.token--pos 0
				span.token--punc ,
				|  
				span.token--arg
					span.token--stop
						span.token--col #{c2}
						|  
						span.token--pos
							span.token--num 35
							span.token--unit px
			span.token--punc )
		
              
            
!

CSS

              
                $lh: 1.75;
$m: .5em;
$p: .75em;
$t: 10s;
$k: 10%;
$bg: #111;
$d: 1em;
$x0: 40%;
$x1: 100% - $x0;
$x2: 7%;
$x3: 100% - $x2;

*, :before, :after {
	--s: calc(1 - 2*var(--i));
	margin: 0;
	padding: 0;
	font: inherit;
	animation-play-state: inherit !important
}

body {
	--m: 1;
	--h: calc(var(--m)*#{$lh}*1em);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	height: 100vh;
	background: #ddd;
	font: 1em/ #{$lh} consolas, monaco, monospace;
	
	@media (max-width: 760px) {
		--m: 2;
		
		.token--arg:nth-child(3):before {
			content: '\A   '
		}
	}

	@media (max-width: 475px) {
		--m: 3;
		
		.token--arg:nth-child(5n + 2):before {
			content: '\A   '
		}
	}
	
	@media (max-width: 320px) { font-size: .75em }
	
	@media (max-width: 240px) { font-size: .5em }
}

input[type='checkbox'] {
	position: absolute;
	transform: translate(-100vw);
	
	+ label {
		position: absolute;
		z-index: 1;
		margin: $p;
		border: solid 2px $bg;
		padding: $p;
		width: $d; height: $d;
		border-radius: 5px;
		background: #FF667A;
		text-indent: -100vw;
		cursor: pointer;
		transition: .5s;
		
		&:before {
			position: absolute;
			top: .5*$p; right: .5*$p; bottom: .5*$p; left: .5*$p;
			background: #000;
			clip-path: polygon($x0 $x2, $x0 $x3, $x2 $x3, $x2 $x2, $x1 $x2, $x3 $x2, $x3 $x3, $x1 $x3, $x1 $x2);
			transition: inherit;
			content: ''
		}
	}
	
	&:checked {
		+ label {
			background: #85EDB0;
			
			&:before {
				clip-path: polygon(50% + $x2 25%, 50% + $x2 75%, 2*$x2 100%, 2*$x2 0, 50% + $x2 25%, 100% 50%, 100% 50%, 50% + $x2 75%, 50% + $x2 25%)
			}
		}
		
		& ~ * { animation-play-state: paused !important }
	}
}

section {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1
}

.rect {
	flex: 1;
	position: relative;
	margin: $m;
	border: dashed 4px #f90;
	max-width: 50em;
	height: calc(100% - 2*#{$m});
	max-height: 30em;
	animation: rect $t linear infinite;
	
	&:before, &:after {
		--i: 0;
		position: absolute;
		top: 0; right: 0; bottom: 0; left: 0;
		background: 
			//linear-gradient(gold 50%, deeppink 0), 
			var(--g0);
		animation: grad0 $t linear infinite;
		content: ''
	}
	
	&:after {
		--i: 1;
		background: var(--g1);
		animation-name: grad1
	}
}

pre {
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-start;
	padding: $p;
	background: linear-gradient($bg, $bg) 0/ 100% no-repeat;
	color: #ddd;
	animation: code $t linear infinite
}

span { display: inline }

.token {
	&--grad {
		--xm: calc(50vw - #{$p} - 50%);
		--ym: calc(var(--h) + .5*(1 - var(--i))*100% - #{$p} - 50vh);
		box-shadow: 0 0 0 $p $bg;
		background: $bg;
		animation: text0 $t linear infinite;
	
		* + &:after {
			animation: inherit;
			animation-name: comma;
			content: ', '
		}
		
		* + & { animation-name: text1 }
	}

	&--func { color: #d285de }

	&--punc { color: #ff667a }

	&--ang { color: #66c7ff }

	&--col { color: #ffeb66 }

	&--pos { color: #85edb0 }
}

@keyframes rect {
	0%, #{2*$k} { transform: translatey(var(--h)) }
	#{3*$k}, #{6*$k} { transform: translatey(calc(.5*var(--h))) }
	#{7*$k}, 100% { transform: none }
}

@keyframes grad0 {
	0% { transform: translate(calc(var(--s)*-100vw)) }
	#{$k}, 100% { transform: none }
}

@keyframes grad1 {
	0%, #{4*$k} { transform: translate(calc(var(--s)*-100vw)) }
	#{5*$k}, 100% { transform: none }
}

@keyframes code {
	0%, #{3*$k} { background-position: -100vw var(--h) }
	#{4*$k}, #{6*$k} { background-position: 0 var(--h) }
	#{7*$k}, 100% { background-position: 0 }
}

@keyframes text0 {
	0% {
		transform: translate(calc(var(--s)*100vw + var(--xm)), var(--ym))
	}
	#{$k}, #{2*$k} {
		transform: translate(var(--xm), var(--ym))
	}
	#{3*$k}, 100% {
		transform: none
	}
}

@keyframes comma {
	0%, #{6*$k} { opacity: 0 }
	#{7*$k}, 100% { opacity: 1 }
}

@keyframes text1 {
	0%, #{4*$k} {
		transform: translate(calc(var(--s)*100vw + var(--xm)), var(--ym))
	}
	#{5*$k}, #{6*$k} {
		transform: translate(var(--xm), var(--ym));
	}
	#{6.625*$k} {
		box-shadow: 0 0 0 $p $bg;
	}
	#{7*$k}, 100% {
		transform: none;
		box-shadow: 0 0 transparent;
	}
}
              
            
!

JS

              
                [...document.querySelectorAll('.token--grad')].forEach((c, i) => document.body.style.setProperty(`--g${i}`, c.textContent));
              
            
!
999px

Console