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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                - let data = [
- 	{ val: 27 }, 
- 	{ val: 74, tip: 1 }
- ];
- let n = data.length;
- let s = min || 0;
- let e = max || max === 0 ? max : 100;

body(style=`--min: ${s}; --max: ${e}`)
	- for(let i = 0; i < n; i++)
		- let r = data[i], id = `r${i}`;
		if r.tip
			.wrap.item(role='group' style=`--val: ${r.val}`)
				input(type='range' id=id min=min value=r.val max=max)
				output(for='id')
		else
			input.item(type='range' id=id min=min value=r.val max=max style=`--val: ${r.val}`)
              
            
!

CSS

              
                $input-s: 0 0 1px #0e0e0e; // shadow for track & tooltip
$input-t: .35s; // transition duration

$track-h: .375em; // track height
$track-r: .5*$track-h; // track end rounding radius

$label-b: .375em; // tooltip border = arrow height
$label-a: 90deg; // tooltip arrow angle
$label-r: .5em; // tooltip bubble corner radius

@mixin track() {
	/* allow thmb border-box range of motion 
	   outside input content-box 
	   if thumb radius > track radius */
	margin: calc(var(--thumb-r) - #{$track-r});
	height: $track-h;
	border-radius: $track-r;
	box-shadow: $input-s;
	background-color: #fff
}

@mixin thumb() {
	border: none;
	width: var(--thumb-d); height: var(--thumb-d);
	border-radius: 50%;
	box-shadow: 
		inset 0 0 var(--thumb-b) #5a5a5a, 
		0 0 var(--thumb-b) #232323;
	background: var(--thumb-c, currentcolor);
	cursor: ew-resize
}

* { margin: 0; padding: 0; color: inherit }

html, body, div { display: grid }

html { min-height: 100% }

.js { --js: 1 }

body {
	--track-w: min(100vw - 4em, 15.5em);
	grid-gap: 2em; /* gap betweeen sliders */
	place-content: center;
	padding: 2em 0;
	background: #3c3c3c;
	font: 1em/ 1.5 ubuntu mono, consolas, monaco, monospace
}

.item {
	--sel: 0;
	--pos: /* current thumb position */
		calc((var(--val) - var(--min))*var(--mover-u) + 
					var(--thumb-r));
	/* thumb range of motion */
	--mover-w: calc(var(--track-w) - #{$track-h});
	--mover-u: calc(var(--mover-w)/(var(--max) - var(--min)));
	--thumb-r: #{$track-r};
	--thumb-d: calc(2*var(--thumb-r));
	place-self: center;
	color: #f64647;
	filter: Saturate(var(--sel)); /* grayscale if not selected */
	transition: filter $input-t;
	
	/* variations for 1st slider */
	&:nth-child(1) {
		--thumb-r: .375em; /* thumb radius */
		--thumb-b: 1px; /* thumb border-width */
		--thumb-c: #fff /* thumb background */
	}
}

/* space between slider and tooltip */
.wrap { grid-gap: .25em }

/* change selection flag */
.item:hover, .wrap:focus-within, 
input[style]:focus { --sel: 1 }

input[type='range'] {
	/* allow custom styling in WebKit browsers */
	&, &::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb { -webkit-appearance: none }
	
	width: calc(var(--mover-w) + var(--thumb-d));
	background: none; /* ditch default white */
	font: inherit; /* default font size is smaller/ inconsistent */
	cursor: pointer;
	
	&::-webkit-slider-container {
		/* override read-only */
		-webkit-user-modify: read-write !important;
		@include track;
		/* JS-depending progress in WebKit browsers */
		background-image: 
			linear-gradient(90deg, 
					currentcolor calc(var(--js)*var(--pos)), 
					transparent 0)
	}
	
	&::-webkit-slider-runnable-track {
		/* enlarge track so its content-box width coincides 
		   with content-box width of input once more */
		margin: 0 calc(#{$track-r} - var(--thumb-r))
	}

	&::-moz-range-track {
		@include track;
		/* cover potential progress gaps at left end of bar */
		background-image: 
			linear-gradient(90deg, 
					currentcolor $track-r, transparent 0)
	}
	
	/* it's complicated, but it's a pure CSS progress in Firefox */
	&::-moz-range-progress {
		height: $track-h; /* override small default height */
		background: currentcolor;
		/* prevent it from spilling outside track boundaries */
		mask: 
			linear-gradient(90deg, 
					red calc(var(--mover-w) + var(--thumb-r)), 
					transparent 0) exclude /* XOR the two layers*/, 
			radial-gradient(circle #{$track-r} at 100%, 
					transparent calc(100% - .5px), 
					red calc(100% + .5px)) 
				0 / var(--thumb-r) 100%;
		mask-repeat: no-repeat;
	}
	
	&::-webkit-slider-thumb { @include thumb }
	
	&::-moz-range-thumb {
		@include thumb;
		/* so masked progreess isn't above thumb */
		transform: translatez(1px)
	}
	
	&:focus { outline: none }

	+ output {
		display: var(--js, none); /* hide in no JS case */
		place-self: start;
		/* zero height to make its cell height zero and prevent 
			 hover action on parent within in its cell space */
		height: 0;
		/* move with thumb */
		transform: translate(calc(var(--pos) - 50%));
		filter: drop-shadow($input-s); /* dark outline */
		/* use value CSS var as counter */
		counter-reset: val var(--val);
		
		&::after {
			display: inherit; /* change inline default */
			/* prevent horizontal overflow on small screens */
			margin: 0 (-1*$label-b);
			/* make space for bubble arrow, 
			   all around for symmetric bubble corner rounding */
			border: solid $label-b transparent;
			padding: 0 min(4vw, #{1.75*$label-r}); /* lateral space */
			border-radius: $label-r + $label-b; /* bubble corner rounding */
			/* grow from middle top on slider hover/ focus */
			transform-origin: 50% 0;
			/* don't chain it to transform on parent 
				 because we only want to animate this one, 
				 scaling, but not translating along slider too */
			transform: scale(var(--sel));
			background: 
				/* arrow part */
				conic-gradient(from 180deg - .5*$label-a at 50% 0, 
						#fff $label-a, transparent 0) 
					50% 0/ 50% 50% no-repeat border-box, 
				/* main bubble part */
				linear-gradient(#fff 0 0) padding-box;
			transition: transform $input-t;
			/* put counter value, taken from CSS var --val, 
			   in content text value */
			content: counter(val) '%'
		}
	}
}
              
            
!

JS

              
                /* external resources *only* for displaying the info boxes */

/* this below is all the JS needed for the demo itself to work */
document.documentElement.classList.add('js');

addEventListener('input', e => {
	let _t = e.target, 
			_p = _t.classList.contains('item') ? _t : _t.parentNode;
	
	_p.style.setProperty('--val', +_t.value)
})
              
            
!
999px

Console