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

              
                - let min = -50, max = 50;
- let thumbs = [
- 	{ val: -15, lbl: 'Value A' }, 
- 	{ val: 20, lbl: 'Value B' }, 
- 	{ val: -35, lbl: 'Value C' }, 
- 	{ val: 45, lbl: 'Value D' }
- ];
- let nv = thumbs.length;
- let layers = thumbs.map((c, i) => `linear-gradient(90deg, red calc(var(--r) + (var(--v${i}) - var(--min))/var(--dif)*var(--uw)), transparent 0)`);

.wrap(role='group' aria-labelledby='multi-lbl' 
			style=`${thumbs.map((c, i) => `--v${i}: ${c.val}`).join('; ')}; 
						 --min: ${min}; --max: ${max};
						 --fill: ${layers.join(', ')}`)
	#multi-lbl Multi thumb slider:
	- for(let i = 0; i < nv; i++)
		label.sr-only(for=`v${i}`) #{thumbs[i].lbl}
		input(type='range' id=`v${i}` min=min value=thumbs[i].val max=max)
		output(for=`v${i}` style=`--c: var(--v${i})`)
              
            
!

CSS

              
                @mixin track() {
	width: 100%; height: 100%;
	background: none /* get rid of Firefox track background */
}

@mixin thumb() {
	border: none; /* get rid of Firefox thumb border */
	width: var(--d); height: var(--d);
	border-radius: 50%; /* make circular */
	background: currentcolor;
	pointer-events: auto
}

/* fix too small font-size in both Chrome & Firefox */
* { font: inherit }

.wrap {
	--w: 20em;
	--h: 2em;
	--d: var(--h);
	--r: calc(.5*var(--d));
	--uw: calc(var(--w) - var(--d));
	--dif: calc(var(--max) - var(--min));
	display: grid;
	grid-template: max-content var(--h)/ var(--w);
	overflow: hidden;
	position: relative;
	margin: 1em auto;
	width: var(--w);
	font-family: ubuntu mono, consolas, monaco, monospace;
	
	&::before, &::after {
		grid-column: 1/ span 2;
		grid-row: 2;
		border-radius: var(--r);
		background: #ccc;
		content: ''
	}
	
	&::after {
		/* non-standard WebKit version */
		-webkit-mask: var(--fill);
		-webkit-mask-composite: xor;
		/* standard version, supported in Firefox */
						mask: var(--fill);
						mask-composite: exclude;
		background: #95a;
	}
}

.sr-only {
	position: absolute;
	clip-path: inset(50%)
}

input[type='range'] {
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb, & {
		-webkit-appearance: none
	}
	
	grid-column: 1;
	grid-row: 2;
	z-index: 1;
	top: 0; left: 0;
	margin: 0;
	background: none; /* get rid of white Chrome background */
	color: #000;
	pointer-events: none;
	
	&::-webkit-slider-runnable-track { @include track }
	&::-moz-range-track { @include track }
	
	&::-webkit-slider-thumb { @include thumb }
	&::-moz-range-thumb { @include thumb }
	
	&:focus {
		z-index: 2;
		outline: solid 0 transparent;
		
		&, & + output { color: darkorange }
	}
}

output {
	position: absolute;
	right: 0;
	color: transparent;
	
	&::after {
		counter-reset: c var(--c);
		content: counter(c)
	}
}
              
            
!

JS

              
                addEventListener('input', e => {
  let _t = e.target;
  _t.parentNode.style.setProperty(`--${_t.id}`, +_t.value)
}, false);
              
            
!
999px

Console