css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

	h3.counter(aria-label="$65.3M") $65.3M
	h3.counter(aria-label="872K") 872K
	h3.counter(aria-label="$491") $491
	h3.counter(aria-label="9875") 9875
              @function rem($px) {
	@return ($px/16px)*1rem;

body {
	font-family: sans-serif;
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 0;
	min-height: 100vh;
	letter-spacing: rem(2px);

.counters {
	display: flex;

.counter {
	position: relative;
	display: flex;
	overflow: hidden;
	align-items: center;
	height: rem(50px);
	font-size: rem(50px);
	color: #333;
	margin: 0 rem(20px) rem(10px);
	& > span {
		z-index: 1;
		display: flex;
		flex-direction: column;
		height: 100%;
		transition: transform 2s ease;
		transform: translateY(0);
		line-height: 1;
		span {
			flex: 0 0 100%;
			height: 100%;
	$d: 0;
	$inc: 0.375;
	@for $i from 1 through 20 {
		&:nth-child(#{$i}) > span {
			transition-delay: #{$d * 1s};
		$d: $d + $inc;

.counter:nth-child(1) {
	color: #EF8354;
.counter:nth-child(2) {
	color: #0EB1D2;
.counter:nth-child(3) {
	color: #2D3142;
.counter:nth-child(4) {
	color: #698F3F;
              // ready check helper function (waits for the dom to load, then returns the indivudual elements one at a time - in case there are more than one of them on the page). I generally use this for all of my dom manipulating scripts so I dont have to type DOMContentLoaded and elems.forEach a hundred times
const ready = (selector, callback) => {
	window.addEventListener('DOMContentLoaded', function () {
		const elems = [...document.querySelectorAll(selector)];
		if (elems.length) {
			for (let elem of elems) {

ready('.counter', (stat) => {
	// pattern used to seperate input number from html into an array of numbers and non numbers. EX $65.3M -> ["$65.3M", "$", "65", ".", "3", "M"]
	const patt = /(\D+)?(\d+)(\D+)?(\d+)?(\D+)?/;
	const time = 1000;
	let result = [...patt.exec(stat.textContent)];
	let fresh = true;
	let ticks;
	// Remove first full match from result array (we dont need the full match, just the individual match groups).
	// Remove undefined values from result array where they didnt have a match in one of the optional regex groups
	result = result.filter(res => res != null);

	while (stat.firstChild) {

	for (let res of result) {
		if (isNaN(res)) {
			stat.insertAdjacentHTML('beforeend', `<span>${res}</span>`);
		else {
			for (let i = 0; i < res.length; i++) {
					`<span data-value="${res[i]}">
						${Array(parseInt(res[i]) + 1).join(0).split(0).map((x, j) => `

	ticks = [...stat.querySelectorAll('span[data-value]')];

	let activate = () => {
		let top = stat.getBoundingClientRect().top;
		let offset = (window.innerHeight * 3 / 4);

		setTimeout(() => {
			fresh = false;
		}, time);

		if (top < offset) {
			setTimeout(() => {
				for (let tick of ticks) {
					let dist = parseInt(tick.getAttribute('data-value')) + 1;
					tick.style.transform = `translateY(-${(dist) * 100}%)`
			}, fresh ? time : 0);
			window.removeEventListener('scroll', activate);
	window.addEventListener('scroll', activate);
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................