cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <body>
	<div id="clock">
		<div class="clock-inner">
			<div class="middle"></div>
			<div class="hand seconds"></div>
			<div class="hand minutes"></div>
			<div class="hand hours"></div>
		</div>
	</div>
	 <a id="hastylink" target="_blank" href="https://www.wp-hasty.com/">Are you a WordPress developer?<br>Then click to check out my latest project Hasty!</a>
</body>
            
          
!
            
              * {
  box-sizing: border-box;
}
html {
	position: relative;
	height: 100%;
}
body {
	position: relative;
	margin: 0;
	padding: 0;
	width: 100%;
	height:100%;
	text-align: center;
	background: #222;
	display: flex;
	align-items: center;
	justify-content: center;
}

#clock {
	position: relative;
	width: 1000px;
	height: 700px;
	margin: 0 auto;
	background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/214624/clock-background.jpg");
	background-position: left center;
	background-size: auto 100%;
	background-repeat: no-repeat;
}
.clock-inner {
	position: absolute;
	width: 367px;
	height: 367px;
	bottom: 35px;
	left: 97px
}
.middle {
	position: absolute;
	background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/214624/clock-middle.png");
	background-size: contain;
	width: 50px;
	height: 50px;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	margin: auto;
	z-index: 2
}
.hand {
	position: absolute;
	background-size: contain;
	background-position: bottom center;
	background-repeat: no-repeat;
	height: 50%;
	width:15px;
	left: 0;
	right: 0;
	top: 0;
	margin: auto;
	transform-origin: 7px 100%;
	transform: rotate(0deg);
	transition: all 1s;
}
.hand.seconds {
	background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/214624/clock-seconds.png");
	transition: all .2s;
	transition-timing-function: cubic-bezier(0.32, 1.73, 0.57, 1.71);
}
.hand.minutes {
	background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/214624/clock-minutes.png");
	background-position-y: 40px;
}
.hand.hours {
	background-image: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/214624/clock-hours.png");
	background-position-y: 100px;
}
#hastylink {
  position: fixed;
  bottom:5px;
  left: 0;
  right: 0;
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  text-align: center;
}
            
          
!
            
              const handSeconds = document.querySelector(".seconds")
const handMinutes = document.querySelector(".minutes")
const handHours = document.querySelector(".hours")

function clockCount() {
	const currentDate = new Date();
	
	// Seconds
	const seconds = currentDate.getSeconds();
	const secondsDegress = (seconds / 60) * 360 + 0;
	handSeconds.style.transform = 'rotate('+secondsDegress+'deg)';
	
	if (seconds == 0) {
		handSeconds.style.transitionDuration = '0s';
	} else {
		handSeconds.style.transitionDuration = '.2s';
	}
	
	// Minutes
	const minutes = currentDate.getMinutes();
	const minutesDegress = (minutes / 60) * 360;
	handMinutes.style.transform = 'rotate('+minutesDegress+'deg)';
	
	if (minutes == 0) {
		handMinutes.style.transitionDuration = '0s';
	} else {
		handMinutes.style.transitionDuration = '1s';
	}
	
	// Hours
	const hours = currentDate.getHours();
	const hoursDegress = (hours / 12) * 360;
	handHours.style.transform = 'rotate('+hoursDegress+'deg)';
	
}
clockCount();
setInterval(clockCount, 1000);
            
          
!
999px
Loading ..................

Console