html5钟表效果
看见有钟表的效果不错:
<!DOCTYPE>
<html lang="en" id="paulrhayes-com" class="js wf-swingdancer1swingdancer2-n5-active wf-active">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/experiment.css"type="text/css">
<link rel="stylesheet" href="css/experiment.css"type="text/css">
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<style type="text/css">
body.experiment {
background: #fff;
}
.start {
text-align: center;
font-size: 2em;
font-weight: bold;
margin: 5em;
}
#clock {
position: relative;
width: 378px;
height: 378px;
background-image: url('http://pic002.cnblogs.com/images/2012/385052/2012031316573623.png');
left: 50%;
margin: 5em 0 0 -189px;
}
#clock p {
position: absolute;
}
</style>
</head>
<body class="experiment">
<p id="wrapper">
<header id="header">
<aside class="tweetThis">
<a href="http://www.cnblogs.com/wangyunbing/" class="twitter-share-button" data-text="CSS3 Analogue Clock" data-count="horizontal" data-via="fofr">滴水成兵</a>
</aside>
</header>
<p id="experiment">
<p id="clock">
<p id="hour"><img src=http://up.2cto.com/2012/0314/20120314095948127.png" alt=""></p>
<p id="minute"><img src=http://up.2cto.com/2012/0314/20120314095948432.png" alt=""></p>
<p id="second"><img src=http://up.2cto.com/2012/0314/20120314095948465.png" alt=""></p>
</p>
</p>
</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">
$(function(){
var props = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '),
prop,
el = document.createElement('p');
for(var i = 0, l = props.length; i < l; i++) {
if(typeof el.style[props[i]] !== "undefined") {
prop = props[i];
break;
}
}
startClock();
setInterval(function(){startClock();},1000)
function startClock() {
var angle = 360/60,
date = new Date(),
hour = (function() {
var h = date.getHours();
if(h > 12) {
h = h - 12;
}
return h
})(),
minute = date.getMinutes(),
second = date.getSeconds(),
hourAngle = (360/12) * hour + (360/(12*60)) * minute;
if(prop) {
$('#minute')[0].style[prop] = 'rotate('+angle * minute+'deg)';
$('#second')[0].style[prop] = 'rotate('+angle * second+'deg)';
$('#hour')[0].style[prop] = 'rotate('+hourAngle+'deg)';
}
}
document.title = date
});
</script>
</body>
</html>
摘自 滴水成兵
推荐阅读
-
一款纯css3实现的机器人看书动画效果_html/css_WEB-ITnose
-
让php支持yar.packager,可以实现文字高亮的效果
-
CDR+PS制作霓虹灯效果的数字10教程
-
AI制作超酷漂亮的金属效果字
-
如何做出图中的效果?(块级元素浮动对齐)_html/css_WEB-ITnose
-
《HTML5权威指南》_html/css_WEB-ITnose
-
html5将来会取代native app 吗,我现在学native app,比如android,会不会白学了,以后被淘汰?
-
实例分享jQuery动态添加.active 实现导航效果代码
-
在制作表格时我们更改表格的边框颜色和背景颜色来达到自己想要的效果
-
Material Design实现悬停效果