Pen Settings

HTML

CSS

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

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

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.

HTML

              
                - var blocks = 68;

.container
	.hr
	.min
	.surface
		- for (var b = 1;b <= blocks;++b) {
			div(class="block b" + b)
				.outer
					.inner
						.front
						.right
						.top
		- }
              
            
!

CSS

              
                $sqSize: 10px;
$contW: 100%;
$contH: 100%;
$xSpaces: 19;
$ySpaces: 19;
$zSpaces: 21;
$xAngle: 75deg;
$zAngle: 30deg;
$prsp: 800px;
$sqrt2: 1.414;

// * Block placement *
// parameters: x-pos,y-pos,z-pos, width,depth,height, color
$blocks:
	// back (.b1–16)
	(3,19,1, 15,1,1, #fff)
	(3,19,2, 1,1,1, #fff)
	(4,19,2, 13,1,1)
	(17,19,2, 1,1,1, #fff)
	(3,19,3, 4,1,1, #fff)
	(7,19,3, 7,1,1)
	(14,19,3, 4,1,1, #fff)
	(2,19,4, 1,1,1, #fff)
	(3,19,4, 15,1,1)
	(2,19,5, 17,1,15)
	(18,19,4, 1,1,1, #fff)
	(1,19,5, 1,1,15, #fff)
	(19,19,5, 1,1,15, #fff)
	(2,19,20, 1,1,1, #fff)
	(18,19,20, 1,1,1, #fff)
	(3,19,21, 15,1,1, #fff)
	// middle (.b17–25)
	(3,2,1, 15,17,3)
	(2,2,4, 17,17,1)
	(1,2,5, 1,17,15)
	(2,2,5, 17,17,15, #fff)
	(19,2,5, 1,17,15)
	(3,19,20, 15,1,1)
	(2,2,20, 17,17,1)
	(3,1,20, 15,1,1)
	(3,2,21, 15,17,1)
	// front (.b26–60)
	(3,1,1, 15,1,1, #fff)
	(3,1,2, 1,1,1, #fff)
	(4,1,2, 13,1,1)
	(17,1,2, 1,1,1, #fff)
	(3,1,3, 4,1,1, #fff)
	(7,1,3, 7,1,1)
	(14,1,3, 4,1,1, #fff)
	(2,1,4, 1,1,1, #fff)
	(3,1,4, 15,1,1)
	(18,1,4, 1,1,1, #fff)
	(1,1,5, 1,1,15, #fff)
	(19,1,5, 1,1,15, #fff)
	(2,1,5, 17,1,1)
	(2,1,6, 2,1,13)
	(4,1,6, 1,1,4)
	(5,1,6, 1,1,2)
	(6,1,6, 2,1,1)
	(13,1,6, 2,1,1)
	(15,1,6, 1,1,2)
	(16,1,6, 1,1,4)
	(10,1,7, 1,1,1)
	(5,1,12, 1,1,1)
	(15,1,12, 1,1,1)
	(4,1,15, 1,1,4)
	(5,1,17, 1,1,2)
	(6,1,18, 2,1,1)
	(10,1,17, 1,1,1)
	(13,1,18, 2,1,1)
	(15,1,17, 1,1,2)
	(16,1,15, 1,1,4)
	(17,1,6, 2,1,13)
	(2,1,19, 17,1,1)
	(2,1,20, 1,1,1, #fff)
	(18,1,20, 1,1,1, #fff)
	(3,1,21, 15,1,1, #fff)
	// clock center (.b61)
	(10,1,12, 1,1,1)
	// hour hand (.b62–64)
	(10,1,12, 1,1,1)
	(10,1,12, 1,1,1)
	(10,1,12, 1,1,1)
	// minute hand (.b65–68)
	(10,1,12, 1,1,1)
	(10,1,12, 1,1,1)
	(10,1,12, 1,1,1)
	(10,1,12, 1,1,1);

// * Mixins *
@mixin placeBlock($args) {
	$defaultArgs: 1 1 1 1 1 1 #333;
	$givenArgs: ();
	
	@for $a from 1 through length($defaultArgs) {
		@if $a <= length($args) {
			$givenArgs: append($givenArgs, nth($args,$a), space);
		} @else {
			$givenArgs: append($givenArgs, nth($defaultArgs, $a), space);
		}
	}

	$x: nth($givenArgs,1);
	$y: nth($givenArgs,2);
	$z: nth($givenArgs,3);
	$w: nth($givenArgs,4);
	$d: nth($givenArgs,5);
	$h: nth($givenArgs,6);
	$c: nth($givenArgs,7);
	
	display: inherit;
	transform: translate3d(
		1em*($x - 1),
		1em*(-$y - ($d - 1)),
		(1em*$z) + (1em*($h - 1))
	);
	.inner div {
		background-color: $c;
		&.top {
			@if $w > 1 {
				width: 1em * $w;
			}
			@if $d > 1 {
				height: 1em * $d;
			}
			transform: rotateX(-90deg) translateY(-1em*($d - 1));
		}
		&.front {
			@if $w > 1 {
				width: 1em * $w;
			}
			@if $h > 1 {
				height: 1em * $h;
			}
			transform: translateZ(1em * ($d - 1));
		}
		&.right {
			@if $d > 1 {
				width: 1em * $d;
			}
			@if $h > 1 {
				height: 1em * $h;
			}
			transform: rotateY(-270deg) translate3d(1em, 0, 1em*($w - $d));
		}
	}
}
@mixin moveBlock($x, $y, $z) {
	transform: translate3d(1em * $x,1em * -$y,1em * $z);
}

// * Normal styles *
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
body {
	font-size: $sqSize;
	height: 100vh;
	margin: 0;
}
.container, .block, .inner > div, .hr, .min {
	position: absolute;
}
.container, .inner > div {
	display: flex;
}
.container, .surface, .block, .outer, .inner {
	transform-style: preserve-3d;
}
.container, .surface {
	margin: auto;
}
.container {
	background: #c0c0c0;
	overflow: hidden;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	width: $contW;
	height: $contH;
	perspective: $prsp;
	will-change: transform;
}
.surface {
	display: block;
	width: 1em * $xSpaces;
	height: 1em * $ySpaces;
	transform: translateY((1em * $zSpaces)/2) rotateX($xAngle) rotateZ($zAngle);
}
.block {
	display: none;
	bottom: 0;
}
.inner > div {
	flex-wrap: wrap;
	align-content: flex-start;
	width: 1em;
	height: 1em;
	&.top, &.right {
		&:before {
			background-color: #000;
			content: "";
			width: 100%;
			height: 100%;
		}
	}
	&.top {
		&:before {
			opacity: 0.2;
		}
	}
	&.right {
		&:before {
			opacity: 0.4;
		}
	}
}
.outer, .inner {
	position: relative;
	width: 1em;
}
.inner {
	transform: rotateX(-90deg) translateZ(1em);
}
.right {
	transform-origin: top right;
}
.top {
	transform-origin: top center;
}

// * Render blocks *
// one block only
@if length(nth($blocks,1)) == 1 {
	.b1 {
		@include placeBlock($blocks);
	}
}
// more than one block
@else {
	@for $b from 1 through length($blocks) {
		.b#{$b} {
			@include placeBlock(nth($blocks, $b));
		}
	}
}

// * Displacement (for animation) *
.hr {
	&._0 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,1);
		}
		.b63 .outer {
			@include moveBlock(0,0,2);
		}
		.b64 .outer {
			@include moveBlock(0,0,3);
		}
	}
	&._0-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,1);
		}
		.b63 .outer {
			@include moveBlock(1,0,2);
		}
		.b64 .outer {
			@include moveBlock(1,0,3);
		}
	}
	&._1 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(1,0,2);
			}
		}
	}
	&._1-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,1);
		}
		.b63 .outer {
			@include moveBlock(2,0,2);
		}
		.b64 .outer {
			@include moveBlock(2,0,2);
		}
	}
	&._2 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(2,0,1);
			}
		}
	}
	&._2-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,0);
		}
		.b63 .outer {
			@include moveBlock(2,0,1);
		}
		.b64 .outer {
			@include moveBlock(3,0,1);
		}
	}
	&._3 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,0);
		}
		.b63 .outer {
			@include moveBlock(2,0,0);
		}
		.b64 .outer {
			@include moveBlock(3,0,0);
		}
	}
	&._3-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,0);
		}
		.b63 .outer {
			@include moveBlock(2,0,-1);
		}
		.b64 .outer {
			@include moveBlock(3,0,-1);
		}
	}
	&._4 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,-1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(2,0,-1);
			}
		}
	}
	&._4-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,-1);
		}
		.b63 .outer {
			@include moveBlock(2,0,-2);
		}
		.b64 .outer {
			@include moveBlock(2,0,-2);
		}
	}
	&._5 ~ .surface {
		.b62 .outer {
			@include moveBlock(1,0,-1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(1,0,-2);
			}
		}
	}
	&._5-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,-1);
		}
		.b63 .outer {
			@include moveBlock(1,0,-2);
		}
		.b64 .outer {
			@include moveBlock(1,0,-3);
		}
	}
	&._6 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,-1);
		}
		.b63 .outer {
			@include moveBlock(0,0,-2);
		}
		.b64 .outer {
			@include moveBlock(0,0,-3);
		}
	}
	&._6-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,-1);
		}
		.b63 .outer {
			@include moveBlock(-1,0,-2);
		}
		.b64 .outer {
			@include moveBlock(-1,0,-3);
		}
	}
	&._7 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(-1,0,-2);
			}
		}
	}
	&._7-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b63 .outer {
			@include moveBlock(-2,0,-2);
		}
		.b64 .outer {
			@include moveBlock(-2,0,-2);
		}
	}
	&._8 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(-2,0,-1);
			}
		}
	}
	&._8-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,0);
		}
		.b63 .outer {
			@include moveBlock(-2,0,-1);
		}
		.b64 .outer {
			@include moveBlock(-3,0,-1);
		}
	}
	&._9 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,0);
		}
		.b63 .outer {
			@include moveBlock(-2,0,0);
		}
		.b64 .outer {
			@include moveBlock(-3,0,0);
		}
	}
	&._9-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,0);
		}
		.b63 .outer {
			@include moveBlock(-2,0,1);
		}
		.b64 .outer {
			@include moveBlock(-3,0,1);
		}
	}
	&._10 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(-2,0,1);
			}
		}
	}
	&._10-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,1);
		}
		.b63 .outer {
			@include moveBlock(-2,0,2);
		}
		.b64 .outer {
			@include moveBlock(-2,0,2);
		}
	}
	&._11 ~ .surface {
		.b62 .outer {
			@include moveBlock(-1,0,1);
		}
		.b63, .b64 {
			.outer {
				@include moveBlock(-1,0,2);
			}
		}
	}
	&._11-5 ~ .surface {
		.b62 .outer {
			@include moveBlock(0,0,1);
		}
		.b63 .outer {
			@include moveBlock(-1,0,2);
		}
		.b64 .outer {
			@include moveBlock(-1,0,3);
		}
	}
}
.min {
	&._0 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,1);
		}
		.b66 .outer {
			@include moveBlock(0,0,2);
		}
		.b67 .outer {
			@include moveBlock(0,0,3);
		}
		.b68 .outer {
			@include moveBlock(0,0,4);
		}
	}
	&._2-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,1);
		}
		.b66 .outer {
			@include moveBlock(1,0,2);
		}
		.b67 .outer {
			@include moveBlock(1,0,3);
		}
		.b68 .outer {
			@include moveBlock(1,0,4);
		}
	}
	&._5 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,1);
		}
		.b66 .outer {
			@include moveBlock(1,0,2);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(2,0,3);
			}
		}
	}
	&._7-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,1);
		}
		.b66 .outer {
			@include moveBlock(2,0,2);
		}
		.b67 .outer {
			@include moveBlock(3,0,3);
		}
		.b68 .outer {
			@include moveBlock(3,0,3);
		}
	}
	&._10 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,1);
		}
		.b66 .outer {
			@include moveBlock(2,0,1);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(3,0,2);
			}
		}
	}
	&._12-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,0);
		}
		.b66 .outer {
			@include moveBlock(2,0,1);
		}
		.b67 .outer {
			@include moveBlock(3,0,1);
		}
		.b68 .outer {
			@include moveBlock(4,0,1);
		}
	}
	&._15 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,0);
		}
		.b66 .outer {
			@include moveBlock(2,0,0);
		}
		.b67 .outer {
			@include moveBlock(3,0,0);
		}
		.b68 .outer {
			@include moveBlock(4,0,0);
		}
	}
	&._17-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,0);
		}
		.b66 .outer {
			@include moveBlock(2,0,-1);
		}
		.b67 .outer {
			@include moveBlock(3,0,-1);
		}
		.b68 .outer {
			@include moveBlock(4,0,-1);
		}
	}
	&._20 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(2,0,-1);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(3,0,-2);
			}
		}
	}
	&._22-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(2,0,-2);
		}
		.b67 .outer {
			@include moveBlock(3,0,-3);
		}
		.b68 .outer {
			@include moveBlock(3,0,-3);
		}
	}
	&._25 ~ .surface {
		.b65 .outer {
			@include moveBlock(1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(1,0,-2);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(2,0,-3);
			}
		}
	}
	&._27-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,-1);
		}
		.b66 .outer {
			@include moveBlock(1,0,-2);
		}
		.b67 .outer {
			@include moveBlock(1,0,-3);
		}
		.b68 .outer {
			@include moveBlock(1,0,-4);
		}
	}
	&._30 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,-1);
		}
		.b66 .outer {
			@include moveBlock(0,0,-2);
		}
		.b67 .outer {
			@include moveBlock(0,0,-3);
		}
		.b68 .outer {
			@include moveBlock(0,0,-4);
		}
	}
	&._32-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,-1);
		}
		.b66 .outer {
			@include moveBlock(-1,0,-2);
		}
		.b67 .outer {
			@include moveBlock(-1,0,-3);
		}
		.b68 .outer {
			@include moveBlock(-1,0,-4);
		}
	}
	&._35 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(-1,0,-2);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(-2,0,-3);
			}
		}
	}
	&._37-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(-2,0,-2);
		}
		.b67 .outer {
			@include moveBlock(-3,0,-3);
		}
		.b68 .outer {
			@include moveBlock(-3,0,-3);
		}
	}
	&._40 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,-1);
		}
		.b66 .outer {
			@include moveBlock(-2,0,-1);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(-3,0,-2);
			}
		}
	}
	&._42-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,0);
		}
		.b66 .outer {
			@include moveBlock(-2,0,-1);
		}
		.b67 .outer {
			@include moveBlock(-3,0,-1);
		}
		.b68 .outer {
			@include moveBlock(-4,0,-1);
		}
	}
	&._45 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,0);
		}
		.b66 .outer {
			@include moveBlock(-2,0,0);
		}
		.b67 .outer {
			@include moveBlock(-3,0,0);
		}
		.b68 .outer {
			@include moveBlock(-4,0,0);
		}
	}
	&._47-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,0);
		}
		.b66 .outer {
			@include moveBlock(-2,0,1);
		}
		.b67 .outer {
			@include moveBlock(-3,0,1);
		}
		.b68 .outer {
			@include moveBlock(-4,0,1);
		}
	}
	&._50 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,1);
		}
		.b66 .outer {
			@include moveBlock(-2,0,1);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(-3,0,2);
			}
		}
	}
	&._52-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,1);
		}
		.b66 .outer {
			@include moveBlock(-2,0,2);
		}
		.b67 .outer {
			@include moveBlock(-3,0,3);
		}
		.b68 .outer {
			@include moveBlock(-3,0,3);
		}
	}
	&._55 ~ .surface {
		.b65 .outer {
			@include moveBlock(-1,0,1);
		}
		.b66 .outer {
			@include moveBlock(-1,0,2);
		}
		.b67, .b68 {
			.outer {
				@include moveBlock(-2,0,3);
			}
		}
	}
	&._57-5 ~ .surface {
		.b65 .outer {
			@include moveBlock(0,0,1);
		}
		.b66 .outer {
			@include moveBlock(-1,0,2);
		}
		.b67 .outer {
			@include moveBlock(-1,0,3);
		}
		.b68 .outer {
			@include moveBlock(-1,0,4);
		}
	}
}
              
            
!

JS

              
                window.addEventListener("load",update);
function numberToClass(n) {
	return String(n).replace("\.","-");
}
function roundToLastN(v,n) {
	return Math.floor(v / n) * n;
}
function update() {
	let time = new Date(),
		hrs = time.getHours() % 12,
		mins = time.getMinutes(),
		hrEl = document.querySelector(".hr"),
		minEl = document.querySelector(".min");

	// round the hour to the last 0.5, replace the decimal with a dash for the CSS class
	hrs = numberToClass(roundToLastN(hrs + mins/60,0.5));
	// same as the hour but to the last 2.5 minutes
	mins = numberToClass(roundToLastN(mins,2.5));
	// apply the classes
	if (hrEl)
		hrEl.className = "hr _" + hrs;
	if (minEl)
		minEl.className = "min _" + mins;
	// loop
	setTimeout(update,1e3);
}
              
            
!
999px

Console