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

              
                .a3d
	- for(let i = 0; i < 12; i++)
		.tri(style=`--i: ${i}`)

p(class='box box--info') Pure CSS halftone effects are something I've been toying with since January 2020. I've given a talk explaining the how behind it (
	a(href='https://codepen.io/thebabydino/project/full/ZjwjBe' target='_blank') slides
	| ) and kept refining the technique since through demos like 
	a(href='https://codepen.io/thebabydino/full/NWxBzRv' target='_blank') these cards
	|  with 
	a(href='https://codepen.io/thebabydino/full/QWMRWRQ' target='_blank') halftone backgrounds
	| , this cute 
	a(href='https://codepen.io/thebabydino/full/LYyNVJQ' target='_blank') dash-dot thing
	| , these 
	a(href='https://codepen.io/thebabydino/full/gOpMeWv' target='_blank') animated patterns
	|  or these 
	a(href='https://codepen.io/thebabydino/full/LYGGwrm' target='_blank') halftone images
	|.
p(class='box box--fail box--property') Sorry, it appears your browser does not support registering custom properties via 
	code @property
	|  (in order to animate them), so the wave animation in this demo does not work, only the cube rotation and the static halftone effect. Here is 
	a(href='https://twitter.com/anatudor/status/1626564518129049600' target='_blank') a recording
	|  of what it should look like.
              
            
!

CSS

              
                @use 'sass:math';

$l: 20em;
$df: $l*math.sqrt(2);
$t: 1s;
$c: #75d9b4, #aa6b71, #f2896f, #ffb87f, #ffec72;

@property --k0 {
	syntax: '<number>';
	initial-value: 0;
	inherits: true
}

html, body, div { display: grid }

html { height: 100% }

div { transform-style: preserve-3d }

body {
	--property-test: block;
	background: #000
}

.a3d {
	place-self: center;
	transform: rotatex(-35deg);
	animation: rot 8*$t linear infinite
}

@keyframes rot {
	to {
		transform: rotatex(-35deg) rotatey(1turn)
	}
}

.tri {
	--k0: 0;
	grid-area: 1/ 1;
	width: .5*$df; height: $l;
	transform: 
		rotate3d(var(--v, 0, 0, 1), 90deg)
		rotatey(calc((var(--i) + .5)*90deg))
		translatex(-50%);
	clip-path: polygon(0 0, 0 100%, 100% 50%);
	animation: k0 1s linear infinite;
	
	&::before, &::after {
		grid-area: 1/ 1;
		content: ''
	}
	
	&::before {
		background: 
			/* pattern */
			radial-gradient(closest-side, #fff, #777 75%) 
					0 0/ 1em 1em round, 
			/* map */
			repeating-radial-gradient(circle at 100%, 
					#777 calc((var(--k0) - 1)*20%), 
					#fff, 
					#777 calc(var(--k0)*20%));
		background-blend-mode: multiply;
		filter: contrast(18);
	}
	
	&::after {
		background: radial-gradient($c);
		mix-blend-mode: darken
	}
	
	&:nth-child(-n + 4) { --v: 0, 1, 0 }
	&:nth-last-child(-n + 4) { --v: 1, 0, 0 }
}

@keyframes k0 { to { --k0: 1 } }

/* support info box styling */
/* for reference: 
 * https://twitter.com/anatudor/status/1601168779651997698 */
@property --property-test {
	syntax: '<custom-ident>';
  initial-value: none;
  inherits: false
}

.box {
	position: fixed;
	inset: auto 1vw 1vh;
	margin: 0;
	border-left: 5px solid #dc3055;
	padding: .625em;
	box-shadow: 2px 2px 5px hsl(0, 0%, 50%);
	background: #851d40;
	color: #fff;
	font: clamp(.625em, 4vw, 1.25em)/ 1.25 trebuchet ms, ubuntu, 
		verdana, arial, sans-serif;
	
	&--info {
		inset: 1vh 1vw auto;
		border-color: #4e8d7c;
		background: #045762
	}
	
	&--property { display: var(--property-test) }
}

code {
	padding: 2px;
	background: hsla(0, 0%, 0%, .2);
	font: 1.1em/ 1.2 ubuntu mono, 
		consolas, monaco, monospace
}

a { color: gold }
              
            
!

JS

              
                /* absolutely no JS πŸ™ƒ */
              
            
!
999px

Console