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

              
                <ol style="--sibling-count: 50;">
	<li style="--sibling-index: 0;"></li>
	<li style="--sibling-index: 1;"></li>
	<li style="--sibling-index: 2;"></li>
	<li style="--sibling-index: 3;"></li>
	<li style="--sibling-index: 4;"></li>
	<li style="--sibling-index: 5;"></li>
	<li style="--sibling-index: 6;"></li>
	<li style="--sibling-index: 7;"></li>
	<li style="--sibling-index: 8;"></li>
	<li style="--sibling-index: 9;"></li>
	<li style="--sibling-index: 10;"></li>
	<li style="--sibling-index: 11;"></li>
	<li style="--sibling-index: 12;"></li>
	<li style="--sibling-index: 13;"></li>
	<li style="--sibling-index: 14;"></li>
	<li style="--sibling-index: 15;"></li>
	<li style="--sibling-index: 16;"></li>
	<li style="--sibling-index: 17;"></li>
	<li style="--sibling-index: 18;"></li>
	<li style="--sibling-index: 19;"></li>
	<li style="--sibling-index: 20;"></li>
	<li style="--sibling-index: 21;"></li>
	<li style="--sibling-index: 22;"></li>
	<li style="--sibling-index: 23;"></li>
	<li style="--sibling-index: 24;"></li>
	<li style="--sibling-index: 25;"></li>
	<li style="--sibling-index: 26;"></li>
	<li style="--sibling-index: 27;"></li>
	<li style="--sibling-index: 28;"></li>
	<li style="--sibling-index: 29;"></li>
	<li style="--sibling-index: 30;"></li>
	<li style="--sibling-index: 31;"></li>
	<li style="--sibling-index: 32;"></li>
	<li style="--sibling-index: 33;"></li>
	<li style="--sibling-index: 34;"></li>
	<li style="--sibling-index: 35;"></li>
	<li style="--sibling-index: 36;"></li>
	<li style="--sibling-index: 37;"></li>
	<li style="--sibling-index: 38;"></li>
	<li style="--sibling-index: 39;"></li>
	<li style="--sibling-index: 40;"></li>
	<li style="--sibling-index: 41;"></li>
	<li style="--sibling-index: 42;"></li>
	<li style="--sibling-index: 43;"></li>
	<li style="--sibling-index: 44;"></li>
	<li style="--sibling-index: 45;"></li>
	<li style="--sibling-index: 46;"></li>
	<li style="--sibling-index: 47;"></li>
	<li style="--sibling-index: 48;"></li>
	<li style="--sibling-index: 49;"></li>
</ol>

<!-- 
this code generates the above. Also add the import to the JS 
import "https://unpkg.com/@bigandy/sibling-count";

<sibling-count>
	<ol>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ol>
</sibling-count> -->
              
            
!

CSS

              
                @layer setup, demo;

@layer demo {
	li {
		--_break-after-x-items: var(--break-after-x-items, 10);
		--_per-item-move: var(--per-item-move, 0);
		--_per-item-angle: var(--per-item-angle, 0);
		--_per-item-angle-color: var(--per-item-angle-color, 5);

		--multiplier: mod(var(--sibling-index), var(--_break-after-x-items));

		translate: calc(var(--multiplier) * var(--_per-item-move) * 1px);
		rotate: calc(var(--multiplier) * var(--_per-item-angle) * 1deg);

		background: hsl(
			calc(var(--multiplier) * var(--_per-item-angle-color) * 1deg) 100% 50%
		);

		/* Want to add a margin-bottom every x items, but without nth-child()	 */
		/* use a clamp() : https://stackoverflow.com/a/64322555		 */

		/* using - 2 because we're using index 0, and also want to add the margin under the item before we are breaking, so 2 before the break-after-x-items */
		--number-to-compare: calc(var(--_break-after-x-items) - 2);
		--large-number: var(--_break-after-x-items);

		--add-margin: clamp(
			0,
			(var(--multiplier) - var(--number-to-compare)) * var(--large-number),
			1
		);

		margin-bottom: calc(var(--add-margin) * 20px);
	}
}

@layer setup {
	ol {
		padding-inline: 0;
		max-inline-size: 300px;
		margin-inline-start: 3rem;
		margin-block: 3rem;

		li {
			height: 10px;
			list-style-type: ""; /* Yes this is a hack to hide the numbers */
			transform-origin: 0 0;

			transition: --rotate 1000ms ease-in-out;
		}
	}

	html {
		scrollbar-gutter: stable;
	}
}

              
            
!

JS

              
                // import "https://unpkg.com/@bigandy/sibling-count@0.2.0/sibling-count.js";

// The custom control panel
import { Pane } from "https://cdn.jsdelivr.net/npm/tweakpane@4.0.5/dist/tweakpane.min.js";

const CTRL = new Pane({
	title: "Controls",
	expanded: true
});

const CONFIG = {
	breakPoint: 10,
	perItemMove: 0,
	perItemAngle: 0,
	perItemAngleColor: 5
};

CTRL.addBinding(CONFIG, "breakPoint", {
	min: 1,
	max: 50,
	step: 1,
	label: "Break after x items"
});

CTRL.addBinding(CONFIG, "perItemMove", {
	min: 0,
	max: 100,
	step: 1,
	label: "Per Item Move (px)"
});

CTRL.addBinding(CONFIG, "perItemAngle", {
	min: 0,
	max: 20,
	step: 0.1,
	label: "Per Item Move (deg)"
});

CTRL.addBinding(CONFIG, "perItemAngleColor", {
	min: 0,
	max: 100,
	step: 1,
	label: "Per Item Color (deg)"
});

const syncVarsToDocumentRoot = () => {
	const documentRootStyle = document.documentElement.style;

	documentRootStyle.setProperty("--break-after-x-items", CONFIG.breakPoint);

	documentRootStyle.setProperty("--per-item-move", CONFIG.perItemMove);

	documentRootStyle.setProperty("--per-item-angle", CONFIG.perItemAngle);

	documentRootStyle.setProperty(
		"--per-item-angle-color",
		CONFIG.perItemAngleColor
	);
};

CTRL.on("change", syncVarsToDocumentRoot);
syncVarsToDocumentRoot();

              
            
!
999px

Console