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 class="clock" role="image">
	<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>
              
            
!

CSS

              
                * { box-sizing: border-box }

body {
	margin: 0;
	min-height: 100vh;
	display: grid;
	place-items: center;
	background: url(https://images.unsplash.com/photo-1533628635777-112b2239b1c7?auto=format&fit=crop&q=80&w=500&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) center/cover; /* background image by thomas heintz on Unsplash */
}

@counter-style upper-roman--iiii {
	range: 4 4;
	system: symbolic;
	symbols: 'I';
	fallback: upper-roman;
}

.clock {
	--style: upper-roman--iiii;
	container-type: inline-size;
	margin: auto;
	padding: 0;
	aspect-ratio: 1;
	width: clamp(8em, 80vmin, 24em);
	border-radius: 50%;
	background: snow;
	outline: thin solid silver;
	box-shadow: .5vmin 1vmin 3vmin gray;
	display: grid;
	list-style: var(--style) inside;
	justify-items: center;
	--partOfMinute: calc(var(--seconds)/60);
	--partOfHour: calc((var(--minutes) + var(--partOfMinute))/60);
		
	&::before, &::after {
		content: '';
		grid-column: 1;
		grid-row: 1;
		width: 7cqw;
	}
	
	&::after {
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-50 -800 100 1600' fill='%23111'%3E%3Cpath d='m13-41a43 43 0 11-26 0v-352c-74-10-12-65-8-112s11-57 9-164q11-4 19 1c1 103 3 114 13 161s59 97-7 115z'/%3E%3C/svg%3E") no-repeat center;
		rotate: calc(var(--partOfHour) * 1turn);
		transition: rotate linear calc(var(--refresh, 0) * 1ms/2);
	}
	
	&::before {
		background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-50 -800 100 1600' fill='%23111'%3E%3Cpath d='m13-41a43 43 0 11-26 0v-192c-74-10-12-65-8-112s11-57 9-164q11-4 19 1c1 103 3 114 13 161s59 97-7 115z'/%3E%3C/svg%3E") no-repeat center;
		rotate: calc((var(--hours) + var(--partOfHour))/12 * 1turn);
	}

	/* preprocessor for convenience */
	@for $i from 1 through 12 {
		&:has(li:nth-of-type(#{$i})) { --count: #{$i} }
		& li:nth-of-type(#{$i}) { --index: #{$i} }
	}

	& li {
		font: 10cqw/1 'Alchemist', serif;
		font-variant-numeric: proportional-nums lining-nums;
		grid-column: 1;
		grid-row: 1;
		place-self: center;
		text-align: center;
		height: 100cqw;
		padding: 3cqw;
		--angle: calc(var(--index) / var(--count) * 1turn);
		rotate: var(--angle);

		&::marker {
			content: counter(list-item, var(--style));
		}
	}
}
              
            
!

JS

              
                const clockElement = document.querySelector('.clock');
const refresh = 500; // ms
if (refresh > 750) {
	clockElement.style.setProperty('--refresh', refresh);
}

clockElement.setTime = function() {
	window.requestAnimationFrame(() => {
		const now = new Date();
		clockElement.style.setProperty('--hours', now.getHours());
		clockElement.style.setProperty('--minutes', now.getMinutes());
		clockElement.style.setProperty('--seconds', now.getSeconds() + now.getMilliseconds()/1000);
	});
}

clockElement.setTime();
window.setInterval(clockElement.setTime, refresh);

// :has() polyfill
if (!CSS.supports('selector(&:has(li:nth-of-type(1)))')) {
	const setCount = (element) => {
		element.style.setProperty('--count', element.childElementCount);
	};

	const countObserver = new MutationObserver(setCount);

	for (let element of document.querySelectorAll('.clock')) {
		setCount(element);
		countObserver.observe(element, {childList: true});
	}
}
              
            
!
999px

Console