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 data = {
- 	function: [ 'round', 'mod', 'rem', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', 'pow', 'sqrt', 'exp', 'log', 'hypot', 'abs', 'sign' ], 
- 	constant: ['e', 'pi', 'infinity', '-infinity']
- };

p Confused about what browser supports what mathematical functions/ constants? This Pen uses 
	code @supports
	|  to tell you what the browser you're currently viewing it in supports and what not.
p As of April 2023, Safari (tested via Epiphany as I'm on Ubuntu) supports everything, Firefox 113 supports everything except 
	code abs()
	|  and 
	code sign()
	|  (which can be easily 
	a(href='https://css-tricks.com/using-absolute-value-sign-rounding-and-modulo-in-css-today/' target='_blank') emulated
	|  using other very well supported functions though), while Chrome 111+ only supports constants and trigonometric functions. Plus 
	code abs()
	|  and 
	code sign()
	|  starting with version 113, as well as all the others starting with version 115, even if only behind the 
	b Experimental Web Platform features
	|  flag (which can be enabled from 
	code chrome://flags
	| ).
- for(let p in data)
	- let a = data[p], n = a.length;
	- for(let i = 0; i < n; i++)
		- let c = a[i];
		- let cond = p === 'function';
		- let url = cond ? 'funcdef' : 'valdef-calc'
		.box(data-feat=`${p}--${c}` data-test='1') Yay, your browser supports the 
			a(href=`https://drafts.csswg.org/css-values-4/#${url}-${c}` target='_blank')
				code #{c}#{cond ? '()' : ''}
			|  #{p}! πŸ₯³ πŸŽ‰
		.box(data-feat=`${p}--${c}`) Sorry, your browser does not support the 
			a(href=`https://drafts.csswg.org/css-values-4/#${url}-${c}` target='_blank')
				code #{c}#{cond ? '()' : ''}
			|  #{p}. 😿
footer
	p The info boxes were created as described in 
		a(href='https://codepen.io/thebabydino/full/qBKvjKM' target='_blank') this Pen
		| .
	p Got any other questions about this? Found any problems with it?
		br
		| You can drop a comment 
		a(href='https://codepen.io/thebabydino/details/yLRBJXP' target='_blank') here
		|  or ping me on 
		a(href='https://mastodon.social/@anatudor' target='_blank' data-ico='🦣') Mastodon
		|  
		|  or on 
		a(href='https://twitter.com/anatudor' target='_blank' data-ico='🐦') Twitter
		| .
	p And if you like the Maths and Physics infused CSS, canvas and SVG work that I've been putting out for over a decade, you can support it by being a cool cat and becoming a patron on 
		a(href='https://www.patreon.com/anatudor' target='_blank') Patreon
		|  or with a one time donation on 
		a(href='https://ko-fi.com/anatudor' target='_blank') Ko-fi
		| . Or at least by sharing this to show the world what can be done with CSS these days... because it's pretty damn cool!
              
            
!

CSS

              
                $s: 4px;

/* ----- relevant styles ----- */
.box {
	/* here's where the cool part starts: 
	 * different styles for the yay/ nay boxes */
	border-left: solid 5px #db3056;
	background: #851d41;
	
	/* a value of 1 if it indicates feature is supported */
	&[data-test='1'] {
		border-color: #4e8d7c;
		background: #045762;
		display: none
	}
	
	/* ----- THE MAGIC ----- */
	
	/* support test for the round() function */
	@supports (z-index: Round(4.1*.5, 1)) {
		&[data-feat='function--round'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the mod() function */
	@supports (z-index: Mod(5, 2)) {
		&[data-feat='function--mod'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the rem() function */
	@supports (z-index: Rem(5, 2)) {
		&[data-feat='function--rem'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the sin() function */
	@supports (top: calc(sin(45deg)*1em)) {
		&[data-feat='function--sin'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the cos() function */
	@supports (top: calc(cos(45deg)*1em)) {
		&[data-feat='function--cos'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the tan() function */
	@supports (top: calc(tan(45deg)*1em)) {
		&[data-feat='function--tan'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the asin() function */
	@supports (rotate: asin(.5)) {
		&[data-feat='function--asin'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the acos() function */
	@supports (rotate: acos(.5)) {
		&[data-feat='function--acos'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the atan() function */
	@supports (rotate: atan(.5)) {
		&[data-feat='function--atan'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the atan2() function */
	@supports (rotate: atan2(4, 3)) {
		&[data-feat='function--atan2'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the pow() function */
	@supports (z-index: pow(2, 2)) {
		&[data-feat='function--pow'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the sqrt() function */
	@supports (z-index: Sqrt(4)) {
		&[data-feat='function--sqrt'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the exp() function */
	@supports (top: calc(Exp(2)*1em)) {
		&[data-feat='function--exp'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the log() function */
	@supports (top: calc(Log(4, 2)*1em)) {
		&[data-feat='function--log'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the hypot() function */
	@supports (top: Hypot(4em, 3em)) {
		&[data-feat='function--hypot'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the abs() function */
	@supports (z-index: Abs(-5)) {
		&[data-feat='function--abs'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the sign() function */
	@supports (z-index: Sign(-5)) {
		&[data-feat='function--sign'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the e constant */
	@supports (top: calc(e*1em)) {
		&[data-feat='constant--e'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the pi constant */
	@supports (rotate: calc(.25turn*pi)) {
		&[data-feat='constant--pi'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the infinity constant */
	@supports (rotate: atan(infinity)) {
		&[data-feat='constant--infinity'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
	
	/* support test for the -infinity constant */
	@supports (rotate: atan(-infinity)) {
		&[data-feat='constant---infinity'] { 
			display: none;
			
			&[data-test='1'] { display: block }
		}
	}
}

/* ----- all the prettifying, less important styles ----- */
body {
	box-sizing: border-box;
	margin: 0 auto;
	max-width: 47em;
	padding: .5em;
	background: #262434;
	color: #fff;
	font: 1.25em/ 1.3 ubuntu, trebuchet ms, sans-serif
}

a {
	--hl: 0;
	position: relative;
	z-index: 1;
	padding: 0 .5*$s;
	color: gold;
	text-decoration: none;
	isolation: isolate;
	
	&::before {
		position: absolute;
		inset: 0;
		transform-origin: 0 100%;
		transform: scaley(calc(var(--hl) - .1*(1 - var(--hl))));
		background: currentcolor;
		mix-blend-mode: difference;
		transition: transform .35s ease-out;
		content: ''
	}
	
	&:focus { outline: none }
	&:hover, &:focus { --hl: 1 }
}

[data-ico] {
	margin-right: 1.5em;
	
	&::after {
		position: absolute;
		left: calc(100% + 2px);
		content: ' ' attr(data-ico)
	}
}

div {
	position: relative;
	margin: .375em 0;
	padding: .25em .5em;
	box-shadow: 0 2px 5px -2px #141414, 
		0 5px 13px -5px #040404
}

code {
	font-family: ubuntu mono, consoas, monaco, monospace;
	font-size: 1.125em	
}

footer {
	font-size: .75em;
	text-align: center
}
              
            
!

JS

              
                
              
            
!
999px

Console