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

              
                <form>
	<section>
		<input id='a0' type='range'/>
		<label for='a0'>--a0: <output for='a0'>.5</output></label>
	</section>
	<section>
		<input id='a1' type='range'/>
		<label for='a1'>--a1: <output for='a1'>.5</output></label>
	</section>
</form>

<main>
	<figure>
		<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2017/17_05_a_amur_leopard_14.jpg' alt='Amur leopard staring the camera with an intrigued look, as if it was preparing to strike'>
		<figcaption>two layers</figcaption>
	</figure>

	<figure>
		<img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2017/17_05_a_amur_leopard_14.jpg' alt='Amur leopard staring the camera with an intrigued look, as if it was preparing to strike'>
		<figcaption>one layer</figcaption>
	</figure>
</main>

<form>
	<section>
		<input type='checkbox' id='img' checked/>
		<label for='img'>Show image</label>
	</section>
</form>
              
            
!

CSS

              
                $thumb-d: 1.5em;
$thumb-r: .5*$thumb-d;
$track-h: .375em;
$track-r: .5*$track-h;
$track-w: 17.5em;
$input-h: 1.5*$thumb-d;
$dots: .1*$track-w;
$bg: #222;
$fg: #eee;
$ll: #bbb;
$hl: #f90;
$t: .3s;

@mixin track() {
	border: none;
	width: 100%; height: $track-h;
	border-radius: $track-r;
	background: $ll;
	background: 
		radial-gradient(circle at calc(var(--pos) + #{$thumb-r}) 50%, 
			transparent $thumb-r, $ll calc(#{$thumb-r} + 1px));
	color: transparent;
}

@mixin thumb() {
	box-sizing: border-box;
	border: none;
	width: $thumb-d; height: $thumb-d;
	transform: scale(calc((.5 + .5*var(--hl))));
	border-radius: 50%;
	background: $hl;
	transition: $t
}

body {
	--a0: .5;
	--a1: .5;
	--img: 1;
	display: grid;
	grid-template-rows: max-content 1fr max-content;
	overflow-x: hidden;
	margin: 0;
	min-width: 275px;
	min-height: 100vh;
	color: $hl;
	font: 900 1em segoe script, comic sans ms, purisa, cursive;
	
	@media (max-width: 400px) { font-size: .875em }
}

form {
	display: flex;
	flex-wrap: wrap;
	width: 100%;
	background: $bg;
	color: $fg;
	font: 1.25em consolas, monospace, ubuntu mono;
	text-align: center;
	
	&:first-child { justify-content: center; }
}

section {
	padding: .5em;
	
	&:nth-child(1) { --a: var(--a0) }
	&:nth-child(2) { --a: var(--a1) }
}

[id], [for] {
	--hl: 0;
	filter: Contrast(var(--hl)) Brightness(calc(2 - var(--hl))) GrayScale(calc(1 - var(--hl)))
}

input {
	&:focus { 
		outline: solid 0 transparent;
		
		&, & ~ [for] { --hl: 1 }
	}
}

input[type='range'] {
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb, & { -webkit-appearance: none }
	
	--pos: calc(var(--a)*#{$track-w});
	display: block;
	border: solid 0 transparent;
	padding: .25em 0;
	width: calc(#{$track-w} + #{$thumb-d});
	height: $input-h;
	background: transparent;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track { @include track }
	
	&::-moz-range-track { @include track }
	
	&::-ms-track { @include track }
	
	&::-webkit-slider-thumb {
		margin-top: .5*($track-h - $thumb-d);
		@include thumb;
	}
	
	&::-moz-range-thumb { @include thumb }
	
	&::-ms-thumb {
		margin-top: 0;
		@include thumb
	}
	
	&::-ms-fill-lower, 
	&::-ms-fill-upper {
		background: transparent;
	}

	&::-ms-tooltip { display: none }
}

input[type='checkbox'] {
	position: absolute;
	right: 100vw;
	clip-path: inset(50%);
	
	+ label {
		display: flex;
		align-items: center;
		
		&::before {
			margin-right: .5em;
			width: $thumb-d; height: $thumb-d;
			border-radius: 5px;
			box-shadow: inset 0 0 0 2px;
			font-weight: 900;
			content: ''
		}
	}
	
	&:checked + label {
		color: $hl;
		
		&::before { content: '✓' }
	}
}

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

figure {
	position: relative;
	margin: .5vmin;
	width: $track-w + $thumb-d;
	
	&:before, &:after {
		position: absolute;
		top: 0; left: 0;
		padding: 50%;
		background: $hl;
		content: ''
	}
	
	&:nth-of-type(1) {
		&:before { opacity: var(--a0) }
		
		&:after { opacity: var(--a1) }
	}
	
	&:nth-of-type(2) {
		&:before { opacity: calc(var(--a0) + var(--a1) - var(--a0)*var(--a1)) }
		
		&:after { opacity: 0 }
	}
}

img {
	width: 100%;
	opacity: var(--img)
}

figcaption { font-size: 1.5em }
              
            
!

JS

              
                function update(e) {
	let _t = e.target, id = _t.id, val;
	
	if(_t.type === 'range') {
		val = +(.01*_t.value).toFixed(2);
		document.querySelector(`output[for='${id}']`).textContent = val;
	}
	if(_t.type === 'checkbox') {
		val = 1*_t.checked;
	}
	
	document.body.style.setProperty(`--${id}`, val);
};

addEventListener('input', update, false);
addEventListener('change', update, false);
              
            
!
999px

Console