Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ add another resource


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


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.


Save Automatically?

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.


                <input type="radio" id="end-0" name="offset" checked />
<input type="radio" id="end-1" name="offset" />
<input type="radio" id="start-1" name="offset" />
<input type="radio" id="start-0" name="offset" />

<div id="controls">
		<h2>Element-Based Offsets<br /><small>Where's #target?</small></h2>
			<li><label for="start-0"><code>start 0</code></label></li>
			<li><label for="start-1"><code>start 1</code></label></li>
			<li><label for="end-1"><code>end 1</code></label></li>
			<li><label for="end-0"><code>end 0</code></label></li>

<div id="browser">
		<div class="box"></div>
	<aside id="scrollbar">
		<div id="thumb"></div>

	<dialog open>
		<h1>About this Pen</h1>
		<p>ℹ️ Scroll-Linked Animations with Element-Based offsets take a somewhat quirky syntax. This tool helps you visualize each selected offset.</p>
		<p>🤔 Want to learn more about Scroll-Linked Animations / Scroll-Timeline? Check out these two articles:</p>
			<li><a href="" target="_top">Scroll-Linked Animations with <code>@scroll-timeline</code> (Part 1) — Introduction</a></li>
			<li><a href="" target="_top">Scroll-Linked Animations with <code>@scroll-timeline</code> (Part 2) — Element-Based Offsets</a></li>
		<p>👀 More animations/visualizations: <a href="" target="_top"></a></p>
		<p>👋 Built by Bramus! — <a href="" target="_top">@bramus</a> - <a href="" target="_top"></a> </p>


                :root {
	--scrollbox-border-size: 1rem;
	--scrollbox-height: 60vh;
	--scrollbox-width: 60vw;
	--box-height: 10vh;
	--box-gap: 5rem;

	--thumb-size: 10vh;

	--scrollbar-width: 0.5rem;

html, body {
	width: 100vw;
	height: 100vh;
	background: #fff;

body {
	display: grid;
	place-items: center;

#browser {
	width: var(--scrollbox-width);
	height: var(--scrollbox-height);
	border: var(--scrollbox-border-size) solid lightblue;

	display: grid;
	grid-template-columns: 1fr var(--scrollbar-width);
	grid-template-rows: 1fr;
	grid-template-areas: "content scrollbar";

	position: relative;

#browser * {
	margin: 0;
	padding: 0;

main {
	display: flex;
	gap: var(--box-gap);
	flex-direction: row;
	position: relative;
	background: #efefef;

main::before, main::after {
	white-space: nowrap;
	display: inline-block;
	position: absolute;
	right: -1em;
	text-transform: uppercase;
	font-size: 0.8rem;

main::before {
	content: 'start edge';
	top: 0;
	transform: translate3d(calc(1em + var(--scrollbox-border-size) + 100%), calc(-50% - var(--scrollbox-border-size) / 2), 0);

main::after {
	content: 'end edge';
	bottom: 0;
	transform: translate3d(calc(1em + var(--scrollbox-border-size) + 100%), calc(50% + var(--scrollbox-border-size) / 2), 0);

#scrollbar {
	grid-area: scrollbar;
	height: 100%;
	align-self: start;

	background: #ccc;

#scrollbar #thumb {
	margin-top: 14vh;
	height: var(--thumb-size);
	width: 100%;
	background: #333;
	border-radius: 9999px;

.box {
	height: var(--box-height);
	flex: 1;

	--shaded-size: 2px;
	--shaded-color: rgba(0 0 0 / 0.12);
	background: repeating-linear-gradient(
      var(--shaded-color) var(--shaded-size),
      transparent var(--shaded-size),
      transparent calc(var(--shaded-size) * 2)
	border: 1px solid #333;

#end-0:checked ~ #browser .box {
	transform: translateY(calc(var(--scrollbox-height) + var(--scrollbox-border-size)));

#end-1:checked ~ #browser .box {
	transform: translateY(calc(var(--scrollbox-height) - var(--box-height)));

#start-1:checked ~ #browser .box {

#start-0:checked ~ #browser .box {
	transform: translateY(calc(-1 * (var(--box-height) + var(--scrollbox-border-size))));

.box::after {
	height: var(--box-height);
	display: grid;
	place-items: center;
	content: '#target';

input {
	display: none;

#controls {
	width: var(--scrollbox-width);
	display: flex;
	justify-content: space-evenly;
	text-align: center;

	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate3d(-50%, -50%, 0);
	z-index: 2;

#controls ul, #controls li {
	list-style: none;
	margin: 0;
	padding: 0;

#controls label {
	cursor: pointer;

#start-0:checked ~ #controls [for='start-0'],
#start-1:checked ~ #controls [for='start-1'],
#end-1:checked ~ #controls [for='end-1'],
#end-0:checked ~ #controls [for='end-0'] {
	font-weight: bold;

#controls [for]::before {
	content: '○ ';

#start-0:checked ~ #controls [for='start-0']::before,
#start-1:checked ~ #controls [for='start-1']::before,
#end-1:checked ~ #controls [for='end-1']::before,
#end-0:checked ~ #controls [for='end-0']::before {
	content: '● ';

/** Poor man's infobox */
details {
	position: fixed;
	bottom: 1em;
	right: 1em;
	font-size: clamp(1.25rem, 2vw, 2rem);
	z-index: 9999;
dialog[open] {
	position: fixed;
	top: 10vmin;
	right: 10vmin;
	bottom: 10vmin;
	left: 10vmin;
	width: auto;
	height: auto;

	/* Extra CSS for Safari … */
	background: #eee;
	border: 0.25em solid lightblue;
	padding: 1em;
	overflow: auto;
details[open] > summary::after {
	content: '';
	position: fixed;
	top: 0; right: 0; bottom: 0; left: 0;
	background: rgba(0 0 0 / 0.5);
	display: block;

/* Hide summary arrow …*/
details summary::-webkit-details-marker {
	display: none;
details summary {
	display: inline-block;
details summary::marker {
	display: none;