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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div class="clock-wrap">
  		<div class="hour-wrap">
				<div class="digit-top">
					<div class="front">12</div>
					<div class="back">12</div>
				</div>
				<div class="digit-bottom">
					<div class="front">12<div class="meridiem">am</div></div>
				</div>
			</div>
			<div class="min-wrap">
				<div class="digit-top">
					<div class="front">12</div>
					<div class="back">24</div>
				</div>
				<div class="digit-bottom">
					<div class="front">12</div>
				</div>
			</div>
		</div>
              
            
!

CSS

              
                
body{
  padding:0px;
  margin:0px;
  background-color:#111;
  background-image: url('http://subtlepatterns.subtlepatterns.netdna-cdn.com/patterns/office.png');
  font-family: 'Oswald', sans-serif;
}


.clock-wrap{
	width:410px;
	
	margin:30px auto 0px auto;
	padding:15px;

	background-color:rgba(0,0,0,.4);
	border-radius: 12px;
	box-shadow:inset 0px 2px 15px rgba(0,0,0,.6);
}

.min-wrap,
.hour-wrap{
	width:200px;
	height:200px;
	
	display: inline-block;
	position: relative;
}

.min-wrap{
	margin-left: 5px;
}


.digit-top, 
.digit-bottom{
	width:200px;
	height:98px;
	position: absolute;
}

.clock-wrap .front, .clock-wrap .back{
	width: 200px;
	height: 98px;
	position: absolute;
	overflow: hidden;

	color:#fff;
	text-align: center;
	font-size: 150px;

	text-shadow:1px 1px 1px #000;
	box-shadow:0px 1px 5px rgba(0,0,0,.6);

	transition: transform 800ms, z-index 800ms;
	-moz-transition: -moz-transform 800ms, z-index 800ms;
	-webkit-transition: -webkit-transform 800ms, z-index 800ms;
	-o-transition: -o-transform 800ms, z-index 800ms;

	background-image: -ms-linear-gradient(bottom, #111111 0%, #222222 100%);
	background-image: -moz-linear-gradient(bottom, #111111 0%, #222222 100%);
	background-image: -o-linear-gradient(bottom, #111111 0%, #222222 100%);
	background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #111111), color-stop(1, #222222));
	background-image: -webkit-linear-gradient(bottom, #111111 0%, #222222 100%);
	background-image: linear-gradient(to top, #111111 0%, #222222 100%);

	-webkit-transform-style: preserve-3d;
  perspective: 200px;
}

.clock-wrap .front{
	z-index: 30;
	
	border-radius: 5px 5px 0px 0px;

	transform-origin: 0px 99px;
	-webkit-transform-origin: 0px 99px;
	-moz-transform-origin: 0px 99px;
	-o-transform-origin: 0px 99px;

	transform: rotateX(0deg);
	-webkit-transform: rotateX(0deg);
	-moz-transform: rotateX(0deg); 
	-o-transform: rotateX(0deg); 
    backface-visibility: hidden;
}

.clock-wrap .back{
	z-index: 20;
	top:100px;

	border-radius: 0px 0px 5px 5px;

	transform-origin: 0px -1px;
	-webkit-transform-origin: 0px -1px;
	-moz-transform-origin: 0px -1px;
	-o-transform-origin: 0px -1px;

	transform: rotateX(180deg);
	-webkit-transform: rotateX(180deg);
	-moz-transform: rotateX(180deg); 
	-o-transform: rotateX(180deg);
    backface-visibility: hidden;

    line-height:5px;
}


.digit-top{
	line-height:200px;
	border-radius:8px 8px 2px 2px;
	top:4px;
	z-index: 10;
}

.digit-bottom{
	top: 104px;
	background-color: #222;
	line-height:5px;
	border-radius:2px 2px 8px 8px;
	z-index: 5;
}

.digit-bottom .front{
	border-radius: 0px 0px 5px 5px;
}

.meridiem{
	font-size: 24px;
	position: absolute;
	left:15px;
	top: 30px;
}

              
            
!

JS

              
                
Element.Properties.transform = {

  set: function(transform){
    var property = 'transform';
		console.log(Browser);
		if(Browser.chrome) property = 'WebkitTransform';
		if(Browser.firefox)  property = 'MozTransform';
		if(Browser.opera) property = 'OTransform';
		
		this.style[property] = transform;
		this.store('transform', transform);
	},

	get: function(){
		return this.retrieve('transform', '');
	}

};

Element.implement({

	setTransform: function(value){
		return this.set('transform', value);
	},

	getTransform: function(){
		return this.get('transform');
	}

});

$(window).addEvent('domready', function()
{
  var $hourWrap = $$('.hour-wrap');
	var $hourFront = $hourWrap.getElement('div.front');
	var $hourBack = $hourWrap.getElement('div.back')
	var $hourTop = $hourWrap.getElement('div.digit-top');
	var $hourBottom = $hourWrap.getElement('div.digit-bottom .front');

	var $minWrap = $$('.min-wrap');
	var $minFront = $minWrap.getElement('div.front');
	var $minBack = $minWrap.getElement('div.back');
	var $minTop = $minWrap.getElement('div.digit-top');
	var $minBottom = $minWrap.getElement('div.digit-bottom .front');

	var currentHour = 0;
	var currentMin = 0;

	var setClock = function()
	{
		var time = new Date();
		var hour = time.getHours();
		var min = time.getMinutes();

		if(currentHour != hour)
		{
			currentHour = hour;
			if(hour > 12)
			{
				var hourText = (hour - 12);
				var meridiem = 'pm';
			}
			else
			{
				var hourText = hour;
				var meridiem = 'am';
			}

			var $meridiem = new Element('div', {'class':'meridiem', 'text':meridiem});

			// make el to sit behind the top digit
			var $newHourTop = new Element('div', {class: 'digit-top', html: $hourTop.get('html'), style: 'z-index:1;'})
			var $newHourFront = $newHourTop.getElement('div.front');
			var $newHourBack = $newHourTop.getElement('div.back');

			$newHourFront.set('text', hourText);
			$hourWrap.adopt($newHourTop);

			// start the animation
			$hourFront.setTransform('rotateX(180deg)');
			$hourBack.setTransform('rotateX(0deg)');

			$hourBack.setStyle('zIndex', 40);

			// set the hour back
			$hourBack.set('text', hourText);
			$hourBack.adopt($meridiem);

			(function()
			{
				$hourTop.destroy();
				$hourFront.destroy();
				$hourBack.destroy();

				$hourTop = $newHourTop;
				$hourFront = $newHourFront;
				$hourBack = $newHourBack;

				$hourTop.setStyle('zIndex', 10);
				$hourBottom.set('text', hourText);
				$hourBottom.adopt($meridiem)
			}).delay(800);
		}

		if(currentMin != min)
		{
			currentMin = min;
			var minText = min < 10 ? '0'+min : min;

			// make el to sit behind the top digit
			var $newMinTop = new Element('div', {class: 'digit-top', html: $minTop.get('html'), style: 'z-index:1;'})
			var $newMinFront = $newMinTop.getElement('div.front');
			var $newMinBack = $newMinTop.getElement('div.back');

			$newMinFront.set('text', minText);
			$minWrap.adopt($newMinTop);

			// start the animation
			$minFront.setTransform('rotateX(180deg)');
			$minBack.setTransform('rotateX(0deg)');
			$minBack.setStyle('zIndex', 40);

			// set the min back
			$minBack.set('text', minText);

			(function()
			{
				$minTop.destroy();
				$minFront.destroy();
				$minBack.destroy();

				$minTop = $newMinTop;
				$minFront = $newMinFront;
				$minBack = $newMinBack;

				$minTop.setStyle('zIndex', 10);
				$minBottom.set('text', minText);
			}).delay(800);
		}

		//$hourEls.set('text', hour);
		
	}

	setClock.periodical(1000);
});
              
            
!
999px

Console