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 a = .65; //- desired alpha
- let u = Math.min(a, 1 + a*a - 2*a); //- base (unit) interval
- let n = Math.ceil(1/u); //- number of intervals
//- alpha point values, most mapped to desired alpha save for 0 and 1
- let v = new Array(n + 1).fill(0).map((_, i) => i*(n - i) ? a : i/n)

mixin text(cls)
	p(class=cls): span: span Socks go missing, vases fall,
		br
		| Claws on curtains, they climb the wall.
		br
		| One swift pounce, a sudden bite,
		br
		| Then they purr like all is right.

body(style=`--a: ${a}`)
	svg(width='0' height='0' aria-hidden='true')
		filter#alpha(color-interpolation-filters='sRGB')
			feComponentTransfer
				feFuncA(type='table' tableValues=v.join(' '))
	
	h2 Problem 😡
	+text
	h2 SVG filter fix πŸ˜ƒ
	+text('fix')
	
	form
		label(for='a') alpha
		input#a(type='range' value=a*100 min='5' max='85')
	
	pre
		span.tkn--punc <
		span.tkn--elem feFuncA
		|  
		span.tkn--attr type
		span.tkn--oper =
		span.tkn--aval 'table'
		|  
		span.tkn--attr tableValues
		span.tkn--oper =
		span.tkn--aval#v '
			- v.forEach((c, i) => {
				if i
					| 
				span.tkn--ival #{c.toString().replace('0.', '.')}
			- })
			| '
		span.tkn--punc />
              
            
!

CSS

              
                /* relevant code */
p {
	/* prevent blending with page backdrop */
	isolation: isolate;
	
	&.fix { filter: url(#alpha) }
}

p > span {
	padding: .5em;
	border-radius: 5px;
	/* for the fix, background must be semi-transparent, 
	 * but the exact final alpha value is set by filter */
	background: rgb(9.8% 9.8% 43.9%/ var(--a));
	color: rgb(100% 64.7% 0%); /* opaque text */
	/* Safari unfortunately still needs the prefix */
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
	
	/* inner span fixes background-letter overlap */
	/* only on the inner one because Firefox */
	/* for dark text on light background, change to darken */
	span { mix-blend-mode: lighten }
}

/* layout, prettifying/ secondary stuff */
$thumb-d: 1.5em;
$thumb-r: .5*$thumb-d;

$track-h: 6px;
$track-r: .5*$track-h;

@mixin thumb($f: 0) {
	@if $f > 0 {
		margin-top: calc(#{$track-r} + -1*#{$thumb-r})
	}
	
	border: solid 2px 
		RGB(from #040404 r g b/ calc(1 - var(--hov)));
	width: $thumb-d;
	height: $thumb-d;
	border-radius: 50%;
	scale: calc(1 - .25*(1 - var(--hov)));
	background: dodgerblue;
	filter: Saturate(var(--hov));
	cursor: ew-resize;
	transition: .35s ease-out
}

@mixin track() {
	height: $track-h;
	border-radius: $track-r;
	background: grey;
}

html, body, form { display: grid }

html { min-height: 100% }

body {
	grid-gap: .5em;
	grid-template-rows: repeat(5, auto) 4lh;
	align-content: center;
	place-items: start center;
	background: 
		url(https://images.unsplash.com/photo-1491485880348-85d48a9e5312?w=2070) 
		50%/ cover #333;
	background-blend-mode: multiply;
	font: clamp(.75em, 5vmin, 2em)/ 1.25 rokkitt, serif
}

/* functionally the same as a style, 
 * take it out of document flow */
svg[height='0'][aria-hidden='true'] { position: fixed }

h2 {
	margin: 0;
	padding: .25em .375em .125em;
	color: tomato;
	background: #000c;
	
	&:has(+ p.fix) { color: yellowgreen }
}

p, pre {
	box-sizing: border-box;
	padding: .5em
}

p {
	justify-self: center;
	margin: 0;
	width: Min(100%, 30em);
	text-align: center
}

form { place-items: center }

label { color: #ededed }

[type='range'] {
	&, &::-webkit-slider-thumb { appearance: none }
	
	--hov: 0;
	width: 20em;
	max-width: 100%;
	background: none;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track { @include track }
	&::-moz-range-track { @include track }
	
	&::-webkit-slider-thumb { @include thumb(1) }
	&::-moz-range-thumb { @include thumb() }
	
	&:focus { outline: none }
	
	&:focus, &:hover { --hov: 1 }
}

pre {
	overflow-x: scroll;
	scrollbar-width: thin;
	scrollbar-color: var(--cs, gold) #0000;
	border: solid 2px #040404;
	width: Min(100%, 40em);
	border-radius: 5px;
	background: #121212;
	color: #ededed;
	font: Max(.75rem, .5em) monospace;
	
	output { display: inline }
	
	@media (min-width: 560px) { --cs: #0000 }
}

[class^='tkn'] {
	&:nth-child(2 of .tkn--attr)::before {
		content: '\A          '
	}
	
	&:not(:first-child):nth-child(11n + 1 of .tkn--ival)::before {
		content: '\A                      '
	}
}

.tkn {
	&--elem { color: #ffcc66 }
	&--attr { color: #66ccff }
	
	&--aval { color: #99cc33 }
	&--ival { color: #ff6699 }
}
              
            
!

JS

              
                const _f = document.querySelector('feFuncA'), 
			_v = document.getElementById('v')

addEventListener('input', e => {
	let _t = e.target, 
			a = +(_t.value*.01).toFixed(2), 
			u = Math.min(a, 1 + a*a - 2*a), 
			n = Math.ceil(1/u), 
			v = new Array(n + 1).fill(0).map((_, i) => i*(n - i) ? a : i/n);
	
	document.body.style.setProperty('--a', a);
	_f.setAttribute('tableValues', v.join(' '));
	_v.innerHTML = `'${v.map(c => `<span class='tkn--ival'>${c.toString().replace('0.', '.')}</span>`).join(' ')}'`;
})
              
            
!
999px

Console