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

              
                - var n_rows = 7, p = [];	

style
	- for(var ridx = 1; ridx < n_rows; ridx++) {
		- var col_lim_inf = n_rows - ridx;
		- var col_lim_sup = n_rows + ridx;
		- var idx_lim_inf = Math.pow(ridx, 2) + 1;
		- var idx_lim_sup = idx_lim_inf + 2*ridx;
		- var a = [[idx_lim_inf], [idx_lim_sup]];
		- var na = a.length;
		- for(var i = 1; i < n_rows - ridx; i++) {
			- for(var j = 0; j < na; j++) {
				- var k = a[j][i - 1] + 2*(i + ridx)
				- a[j].push(k);
			- }
		- }
		- var sel = `.s3gon:nth-child(n + ${idx_lim_inf}):nth-child(-n + ${idx_lim_sup})`
		- if(ridx%2)
			- p.push(sel)
		| #{sel} { --ridx: #{ridx + 1} }
		| .s3gon:nth-child(#{a[0].join('), .s3gon:nth-child(')}) { --cidx: #{col_lim_inf} }
		| .s3gon:nth-child(#{a[1].join('), .s3gon:nth-child(')}) { --cidx: #{col_lim_sup} }
	- }
	| #{p.join(', ')} { --p0: -1 }
.grid(style=`--n-rows: ${n_rows}; --n-cols: ${2*n_rows + 1}; --cidx: ${n_rows}`)
	- for(var ridx = 0; ridx < n_rows; ridx++)
		- for(var cidx = n_rows - ridx; cidx <= n_rows + ridx; cidx++)
			.s3gon
              
            
!

CSS

              
                @import 'compass/css3';

@function getPolyPoints(
		$n: 3 /* number of poly vertices */, 
		$oa: -90deg /* angular offset of 1st poly vertex */, 
		$bw: 2px /* polygon border-width */) {
	
	$ba: 360deg/$n; // base angle corrensponding to 1 poly edge
	$l0: (); // list of points, initially empty
	$l1: (); // list of points, initially empty
	
	@for $i from 0 through $n {
		$ca: $i*$ba + $oa; // angle current point is at wrt x axis
		$x: calc(50%*(1 + #{cos($ca)})); // x coord of current point
		$y: calc(50%*(1 + var(--p)*#{sin($ca)})); // y coord of current point
		$l0: $l0, $x $y; // add current point coords to points list
		$ca: -$i*$ba + $oa; // angle current point is at wrt x axis
		$x: calc(50% + (50% - #{$bw})*#{cos($ca)}); // x coord of current point
		$y: calc(50% + (50% - #{$bw})*var(--p)*#{sin($ca)}); // y coord of current point
		$l1: $l1, $x $y // add current point coords to points list
	}
	
	@return join($l0, $l1, comma)
}

$c: #ff1ead;
$l: 6.5vmin;
$t: 1s;

$n3gon: 3;
$ba3gon: 360deg/$n3gon;
$rc3gon: .5*$l/sin(.5*$ba3gon);
$dc3gon: 2*$rc3gon;
$ri3gon: .5*$l/tan(.5*$ba3gon);
$h3gon: .5*$l*sqrt(3);
$mv: .5*($h3gon - $dc3gon);
$mh: .5*(.5*$l - $dc3gon);

body {
	display: grid;
	place-content: center;
	margin: 0;
	height: 100vh;
	background: $c
}

.grid {
	display: grid;
	padding: -$mv (-$mh);
	//filter: drop-shadow(2px 2px 5px)
}

.s3gon {
	--m: calc(.5*(1 - var(--p0, 1)*var(--p1, 1)));
	--p: calc(2*var(--m) - 1);
	grid-row: var(--ridx);
	grid-column: var(--cidx, var(--n-rows));
	position: relative;
	margin: calc(#{$mv} - (1 - var(--m))*#{$ri3gon}) $mh;
	width: $dc3gon; height: $dc3gon;
	background: currentcolor;
	color: #000;
	clip-path: polygon(getPolyPoints());
	animation: size $t infinite alternate;
	animation-delay: calc(var(--cidx)*#{-$t}/var(--n-cols));
	animation-duration: $t, 2*$t;
	animation-name: size, cinv, fill;
	animation-timing-function: ease-in, steps(1), ease-out;

	&:nth-child(odd) { --p1: -1 }
}

@keyframes size { 95%, 100% { transform: scale(0) } }

@keyframes fill { 95%, 100% { clip-path: polygon(getPolyPoints($bw: 50%)) } }

@keyframes cinv { 50% { color: #fff } }
              
            
!

JS

              
                // no JS here, but check out version #1 of this demo https://codepen.io/thebabydino/pen/KJddbK
              
            
!
999px

Console