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.

            
              <div class="container">
	<div class="spotlight"></div>
	<div class="cat">
		<div class="ear left"></div>
		<div class="ear right"></div>
		<div class="head">
			<div class="stripe top"></div>
			<div class="stripe"></div>
			<div class="stripe lower"></div>
			<div class="stripe right"></div>
			<div class="stripe right lower"></div>
			<div class="eyes">
				<div class="eye left">
					<div class="iris">
						<div class="pupil"></div>
					</div>
				</div>
				<div class="eye right">
					<div class="iris">
						<div class="pupil"></div>
					</div>
				</div>
			</div>
			<div class="nose"></div>
			<div class="mouth"></div>
		</div>
		<div class="body"></div>
		<div class="paw left"></div>
		<div class="paw right"></div>
		<div class="leg left"></div>
		<div class="leg right"></div>
		<div class="tail"></div>
	</div>
	<div class="clock">
		<div class="date">
			<div class="month" id="month"></div>
			<div class="day" id="day"></div>
		</div>
		<div class="numbers">
			<div class="number number-1"> <span>1</span></div>
      <div class="number number-2"> <span>2</span></div>
      <div class="number number-3"> <span>3</span></div>
      <div class="number number-4"> <span>4</span></div>
      <div class="number number-5"> <span>5</span></div>
      <div class="number number-6"> <span>6</span></div>
      <div class="number number-7"> <span>7</span></div>
      <div class="number number-8"> <span>8</span></div>
      <div class="number number-9"> <span>9</span></div>
      <div class="number number-10"> <span>10</span></div>
      <div class="number number-11"> <span>11</span></div>
      <div class="number number-12"> <span>12</span></div>
		</div>
		
		<div class="hours-container">
			<div class="hours"></div>
		</div>
		<div class="minutes-container">
			<div class="minutes"></div>
		</div>
		<div class="seconds-container">
			<div class="seconds"></div>
		</div>	
		
	</div>
</div>
            
          
!
            
              * {
	padding: 0;
	margin: 0;
	box-sizing: border-box;
}

$nutmeg: #663300;
$buddha: #CC9900;
$madras: #333300;
$tawny: #CC6600;
$cat: #6f6f6f;
$forestgreen: lighten(desaturate(#228B22, 35%), 20%);

@mixin box-shadow {
	box-shadow: 5px 10px 30px rgba(#000, 0.18);
}

body {
	background: repeating-linear-gradient(
		to right,
		$forestgreen,
		$forestgreen 30px,
		lighten($forestgreen, 20%) 30px,
	  lighten($forestgreen, 20%) 60px
	);
	overflow-x: hidden;
}

.container {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	height: 100vh;
	width: 100vw;
	position: relative;
}

.spotlight {
	background: #f1f1f1;
	border-radius: 50%;
	filter: opacity(0.1) blur(15px);
	position: absolute;
	width: 600px;
	height: 600px;
	z-index: 100;
}

.clock {
	background-color: #f1f1f1;
	border: 8px solid $nutmeg;
	border-radius: 50%;
	box-shadow: 0 0 2px $madras inset, 0px 2px 5px rgba(0,0,0,0.25) inset, 5px 10px 30px rgba(#000, 0.1);
	font-family: 'Spirax', cursive;
	position: relative;
	min-width: 200px;
	min-height: 200px;
	
	&:after {
		background: #333;
		border-radius: 50%;
		content: '';
		position: absolute;
		left: 50%;
		top: 50%;
  	transform: translate(-50%, -50%);
		width: 10px;
		height: 10px;
  	z-index: 10;
	}
}

.date {
	background: linear-gradient(to bottom, $madras, $cat, $madras);
	box-shadow: 1px 1px 1px $madras inset;
	color:  darken(#f1f1f1,10%);
	display: flex;
	position: absolute;
	border: 2px solid $nutmeg;
	overflow: hidden;
	height: 20px;
	width: 60px;
	right: 0;
	left: 0;
	margin: 0 auto;
	bottom: 45px;
}

.month,
.day {
	align-items: center;
	display: flex;
	filter: opacity(0.9);
	flex-basis: 50%;
	height: 100%;
	position: relative;
	text-align: center;
}

.month {
	justify-content: center;
	
	&::before {
		background: linear-gradient(to bottom, darken(#f1f1f1,50%), darken(#f1f1f1,15%), darken(#f1f1f1,50%));
		content: '';
		display: block;
		right: 0;
		position: absolute;
		width: 1px;
		height: 100%;
	}
}

.day {
	justify-content: flex-end;
	letter-spacing: 4px;
	flex-grow: 1;
	
	&::before {
		background: linear-gradient(to bottom, darken(#f1f1f1,50%), darken(#f1f1f1,15%), darken(#f1f1f1,50%));
		content:'';
		display: block;
		position: absolute;
		left: 0;
		right: 0;
		margin: 0 auto;
		height: 100%;
		width: 1px
	}
}

.numbers {
	color: $madras;
	position: relative;
}

.number{
  position: absolute;
  height: 90px;
  transform-origin: 0 100%;
	left: 50%;
	top: 3px;
  font-size: 24px;
  
  @each $n in 1,2,3,4,5,6,7,8,9,10,11,12 {
    $amt:360/12*$n - 5; //- 2 to level out text
    &:nth-child(#{$n}){
      transform: rotate($amt+deg);
      
      span{
        display:block;
        transform:rotate( (-$amt)+deg);
      }
    }
  }
}

.minutes-container, .hours-container, .seconds-container {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.hours-container {
  animation: rotate 43200s infinite linear;
}
.minutes-container {
  transition: transform 0.3s cubic-bezier(.4,2.08,.55,.44);
}
.seconds-container {
  transition: transform 0.2s cubic-bezier(.4,2.08,.55,.44);
}

.hours,
.minutes,
.seconds {
	background: $madras;
	box-shadow:2px 2px 3px rgba(#000, 0.2);
  position: absolute;
}

.hours {
  height: 25%;
  left: calc(50% - 1.5px);
  top: 25%;
  transform-origin: bottom center;
  width: 3px;
	
	&::before,
	&::after {
		content: '';
		display: block;
		position: absolute;		
	}
	
	&::before {
		background: $madras;
		border-radius: 50%;
		left: -3.5px;
		top: 50%;
		width: 10px;
		height: 10px;
	}
	
	&::after {
		border: 5px solid transparent;
		border-bottom: 24px solid $madras;
		left: -3.5px;
		top: -3px;
	}
}

.minutes {
  height: 40%;
  left: calc(50% - 1.5px);
  top: 10%;
  transform-origin: 50% 100%;
  width: 3px;
	
	&::before,
	&::after {
		content: '';
		display: block;
		position: absolute;		
	}
	
	&::before {
		background: $madras;
		border-radius: 50%;
		left: -3.5px;
		top: 50%;
		width: 10px;
		height: 10px;
	}
	
	&::after {
		border: 5px solid transparent;
		border-bottom: 24px solid $madras;
		left: -3.5px;
		top: 11px;
	}
}

.seconds {
  background: red;
  height: 45%;
  left: 49.5%;
  top: 14%;
  transform-origin: 50% 80%;
  width: 1%;
  z-index: 8;
	
	&::before {
		background: red;
		border-radius: 50%;
		content: '';
		display: block;
		width: 6px;
		height: 6px;
		bottom: 0;
		left: -2px;
		position: absolute;
	}
}

@keyframes rotate {
  100% {
    transform: rotateZ(360deg);
  }
}

.cat {
	position: relative;
}

.ear {
	position: absolute;
	width: 0;
	height: 0;
	top: 5px;
	z-index: -1;

	border-left: 30px solid transparent;
	border-right: 30px solid transparent;
	border-bottom: 40px solid darken($cat, 10%);
	
	&::before {
		content: '';
		display: block;
		position: absolute;
		left: -18px;
		top: 5px;
		width: 0;
		height: 0;
		
		border-left: 18px solid transparent;
		border-right: 18px solid transparent;
		border-bottom: 30px solid $nutmeg;
	}
	
	&.left {
		left: -5px;
		transform: rotate(-30deg);
	}
	
	&.right {
		right: -5px;
		transform: rotate(30deg);
	}
}

.head {
	background: $cat;
	border: 2px solid darken($cat, 10%);
	border-radius: 100px/75px;
	width: 175px;
	height: 150px;
	overflow: hidden;
	position: relative;
	top: 20px;
	z-index: -1;
}

.ear {
	
}

.stripe {
	position: absolute;
	top: 50px;
	width: 0;
	height: 0;
	border-top: 10px solid transparent;
	border-left: 20px solid $madras;
	border-bottom: 10px solid transparent;
	
	&.top {
		margin: 0 auto;
		left: 0;
		right: 0;
		top: 0px;
		transform: rotate(90deg) scale(2);
	}
	
	&.lower {
		top: 80px;
	}
	
	&.right {
		right: 0px;
		transform: rotate(180deg);
	}
}

.eyes {
	position: relative;
	width: 110px;
	height: 20px;
	margin: 0 auto;
	top: 40px;
}

.eye {
	background-color: #f1f1f1;
	border: 1px solid darken($cat, 20%);
	border-radius: 50%;
	position: absolute;
	width: 50px;
	height: 50px;
	
	&.right {
		right: 0px;
	}
}

.iris {
	background: $tawny;
	border-radius: 50%;
	width: 20px;
	height: 100%;
	margin: 0 auto;
	left: 0;
	right: 0;
}

.pupil {
	background: $madras;
	border-radius: 15px/50px;
	height: 90%;
	width: 10px;
	left: 0;
	right: 0;
	top: 5%;
	margin: 0 auto;
	position: absolute;
}

.nose {
	margin: 0 auto;
	position: relative;
	top: 70px;
	width: 0;
	height: 0;

	border-left: 8px solid transparent;
	border-right: 8px solid transparent;
	border-top: 12px solid $nutmeg;
}

.mouth {
	background: repeating-linear-gradient(
	to right,
  #000,
  #000 1px,
  #f1f1f1 1px,
  #f1f1f1 15px);
	border: 1px solid #000;
	border-radius: 50%;
	width: 130px;
	height: 110px;
	position: absolute;
	left: 0;
	right: 0;
	top: 30px;
	margin: 0 auto;
	z-index: -1;
	
	&::after {
		background: $cat;
		border: 1px solid $cat;
		border-bottom: 1px solid #000;
		border-radius: 50%;
		content: '';
		display: block;
		width: 110%;
		height: 100%;
		left: -5%;
		right: 0;
		position: absolute;
		top: -20px;
		z-index: 20;
	}
}

.body {
	background: $cat;
	border: 2px solid darken($cat,10%);
	border-top-left-radius: 50%;
	border-top-right-radius: 50%;
	position: absolute;
	bottom: -55px;
	height: 80px;
	width: 100%;
	z-index: -2;
}

.paw {
	background: $cat;
	border: 2px solid darken($cat,10%);
	border-top-color: $cat;
	border-bottom-right-radius: 50%;
	border-bottom-left-radius: 50%;
	width: 40px;
	height: 35px;
	overflow: hidden;
	position: absolute;
	bottom: -50px;
	z-index: 10;
	
	&::before,
	&::after {
		background: darken($cat, 10%);
		content: '';
		display: block;
		bottom: 0;
		width: 2px;
		height: 15px;
		position: absolute;
	}
	
	&::before {
		left: 12px;
	}
	
	&::after {
		right: 12px;
	}
	
	&.left {
		left: 4px;
		transform: rotate(-15deg);
	}
	
	&.right {
		right: 8px;
		transform: rotate(40deg);
	}
}

.leg {
	background: $cat;
	border: 2px solid darken($cat, 10%);
	border-bottom-right-radius: 20px;
	border-bottom-left-radius: 20px;
	bottom: -200px;
	position: absolute;
	width: 40px;
	height: 80px;
	
	&::before,
	&::after {
		background: darken($cat, 10%);
		content: '';
		display: block;
		bottom: 0;
		width: 2px;
		height: 15px;
		position: absolute;
	}
	
	&::before {
		left: 12px;
	}
	
	&::after {
		right: 12px;
	}
	
	&.right {
		right: 0;
	}
}

.tail {
	animation: rotate-tail 2s ease-in-out infinite;
	background: linear-gradient(
		to bottom,
		$cat,
		$cat 50%,
		$madras 50%,
		$madras
	);
	background-size: 100% 30px;
	border: 2px solid darken($cat, 10%);
	border-bottom-right-radius: 15px;
	border-bottom-left-radius: 15px;
	bottom: -300px;
	@include box-shadow;
	left: 0;
	right: 0;
	margin: 0 auto;
	width: 30px;
	height: 150px;
	position: absolute;
	transform-origin: top center;
	z-index: -1;
}

@keyframes rotate-tail {
  0%, 100% {
    transform: rotate(45deg);
  }
  50% {
    transform: rotate(-45deg);
  }
}
            
          
!
            
              var date = new Date();

initClock();
moveSecondHands();
setUpMinuteHands();
setDate();

function setDate() {
	let day = this.date.getDate().toString().padStart(2,0);
	let month = this.date.toLocaleString("en-us", { month: "short" });

	document.getElementById("month").innerHTML = month;
	document.getElementById("day").innerHTML = day;
}

function initClock() {
	let hands = [
		{
			hand: "hours",
			angle: this.date.getHours() * 30 + this.date.getMinutes() / 2
		},
		{
			hand: "minutes",
			angle: this.date.getMinutes() * 6
		},
		{
			hand: "seconds",
			angle: this.date.getSeconds() * 6
		}
	];

	for (let j = 0; j < hands.length; j++) {
		let elements = document.querySelectorAll("." + hands[j].hand);
		for (let k = 0; k < elements.length; k++) {
			elements[k].style.webkitTransform = "rotateZ(" + hands[j].angle + "deg)";
			elements[k].style.transform = "rotateZ(" + hands[j].angle + "deg)";
			// If this is a minute hand, note the seconds position (to calculate minute position later)
			if (hands[j].hand === "minutes") {
				elements[k].parentNode.setAttribute(
					"data-second-angle",
					hands[j + 1].angle
				);
			}
		}
	}
}

function setUpMinuteHands() {
	// Find out how far into the minute we are
	let containers = document.querySelectorAll(".minutes-container");
	let secondAngle = containers[0].getAttribute("data-second-angle");
	if (secondAngle > 0) {
		// Set a timeout until the end of the current minute, to move the hand
		let delay = ((360 - secondAngle) / 6 + 0.1) * 1000;
		setTimeout(function() {
			moveMinuteHands(containers);
		}, delay);
	}
}

/*
 * Do the first minute's rotation
 */
function moveMinuteHands(containers) {
	for (let i = 0; i < containers.length; i++) {
		containers[i].style.webkitTransform = "rotateZ(6deg)";
		containers[i].style.transform = "rotateZ(6deg)";
	}
	// Then continue with a 60 second interval
	setInterval(function() {
		for (let i = 0; i < containers.length; i++) {
			if (containers[i].angle === undefined) {
				containers[i].angle = 12;
			} else {
				containers[i].angle += 6;
			}
			containers[i].style.webkitTransform =
				"rotateZ(" + containers[i].angle + "deg)";
			containers[i].style.transform = "rotateZ(" + containers[i].angle + "deg)";
		}
	}, 60000);
}

function moveSecondHands() {
	let containers = document.querySelectorAll(".seconds-container");
	setInterval(function() {
		for (let i = 0; i < containers.length; i++) {
			if (containers[i].angle === undefined) {
				containers[i].angle = 6;
			} else {
				containers[i].angle += 6;
			}
			containers[i].style.webkitTransform =
				"rotateZ(" + containers[i].angle + "deg)";
			containers[i].style.transform = "rotateZ(" + containers[i].angle + "deg)";
		}
	}, 1000);
}

            
          
!
999px
🕑 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.

Console