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

              
                - var min = 1, max = 9, val = 3;

style :root { --min: #{min}; --val: #{val}; --max: #{max}; --ceil: #{Math.ceil(.5*val)}; --down: #{Math.floor(.5*val)}; --odd: #{val%2} }
input#n(type='range' min=min max=max value=val)
label(for='n') Number of items
output(for='n') #{val}
p
section
	ul
		- for(var i = 1; i <= max; i++)
			li nth: <code>#{i}</code>
	.guides
		.guide
			code :nth-child(-n + <span>#{Math.ceil(.5*val)}</span>)
			.num first <code>2</code> items
		.guide
			code :nth-child(n + <span>#{~~(.5*val) + 1}</span>)
			.num first item
              
            
!

CSS

              
                $track-w: 12.5em;
$track-h: .25em;
$thumb-d: 1.5em;

$p: calc(2vw + .25em);
$m: 1.5em;

@mixin track() {
	box-sizing: border-box;
	border: none;
	width: $track-w; height: $track-h;
	background: #ccc;
}

@mixin thumb() {
	box-sizing: border-box;
	border: none;
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	background: #f90
}

*, :after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	font: inherit
}

body {
	--s: 0;
	--b: calc(.97*(100vw - 8*#{$p})/(var(--max) + 1));
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	overflow: hidden;
	font: 1.25em/2 comic sans ms, sans-serif;
	
	@media (max-width: 430px) { --b: 1.5em }
}

input {
	&, &::-webkit-slider-thumb {
		-webkit-appearance: none
	}
	
	margin: 0 $p;
	padding: 0;
	width: $track-w; height: $thumb-d;
	background: transparent;
	
	&::-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
	}
}

label, p {
	padding: .5em $p;
	width: 100vw
}

label {
	order: -1;
	
	&:after { content: ':' }
}

code {
	font-family: consolas, monaco, monospace
}

section {
	position: relative;
	margin: 0 auto;
	padding: 4em 0;
}

ul {
	display: flex;
	list-style: none
}

li {
	--m: 0;
	--d: calc(var(--s)*var(--b));
	--p: calc(var(--s)*#{$m});
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	border: none;
	padding: 3px;
	width: var(--d); height: var(--d);
	min-width: var(--p); min-height: var(--p);
	border-radius: 50%;
	opacity: var(--s);
	background: hsl(37, calc(var(--m)*100%), 50%) content-box
}

.guides {
	position: absolute;
	top: 0; right: 0; bottom: 0; left: 0;
	
	div, .guide > code { position: absolute }
}

.guide {
	--f: 0;
	--k: calc(2*var(--f) - 1);
	width: 100%; height: 100%;
	--c: hsl(calc(15 + var(--f)*295), calc(57% - var(--f)*14%), 50%);
	color: var(--c);
	mix-blend-mode: screen;
	
	> code, .num {
		border: solid 0 var(--c);
		min-width: 430px; width: 100vw;
		text-align: right;
		white-space: nowrap
	}
	
	> code {
		bottom: 0;
		border-width: 0 calc((1 - var(--f))*2px) 2px calc(var(--f)*2px);
		padding: 0 calc((1 - var(--f))*var(--b)) 1em calc(var(--f)*var(--b));
		transform: translate(calc(((1 - var(--f))*(var(--ceil)) + var(--f)*(var(--down)))*var(--b) - (1 - var(--f))*100%));
		background: repeating-linear-gradient(calc(var(--k)*45deg), 
		var(--c) 0, var(--c) 2px, transparent 2px, transparent 7px) 0 100%/ 100% 1em no-repeat;
	}
	
	&:last-of-type code { bottom: .375em }
	
	.num {
		border-width: 2px 2px 0 0;
		padding: 0 .5em;
		transform: 
			translate(calc((var(--ceil) - var(--odd, 0)*var(--f))*var(--b) - 100%), 
								calc(var(--odd)*(var(--f))*100%));
	}
	
	&:nth-child(2) {
		--f: 1;
		
		> code { text-align: left }
	}
}
              
            
!

JS

              
                const _A = document.getElementById('n'), 
			_O = document.querySelector(`output[for='n']`), 
			_C = document.querySelectorAll(`.guide code span`), 
			_N = document.querySelectorAll(`.num`), 
			_S = document.createElement('style');

let a = null;

function update() {
	if(a !== +_A.value) {		
		_O.textContent = a = +_A.value;
		
		let ceil = Math.ceil(.5*a), 
				down = ~~(.5*a), odd = a%2;
		
		document.body.style.setProperty('--val', a);
		document.body.style.setProperty('--ceil', ceil);
		document.body.style.setProperty('--down', down);
		document.body.style.setProperty('--odd', odd);
		
		_C[0].textContent = ceil;
		_C[1].textContent = down + 1;
		
		_N[0].textContent = `first ${ceil > 1 ? `${ceil} items` : 'item'}`;
		_N[1].textContent = down > 0 ? 
			`first ${down > 1 ? `${down} items` : 'item'}` : 
			'no items';
		
		_S.textContent = `li:nth-child(-n + ${a}) { --s: 1 }`
		if(a%2) 
			_S.textContent += `li:nth-child(${Math.ceil(.5*a)}) { --m: 1 }`
	}
}

update();
document.body.appendChild(_S);

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

Console