关闭

jQuery+css3网页时钟效果

442人阅读 评论(0) 收藏 举报
分类:

css3网页时钟,圆形的电子钟表信息,基于HTML5技术,IE下不能正常运行,有些内容是使用图片实现的,有兴趣的参考下吧。


<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery+css3网页时钟效果</title>
<style>
*{margin: 0;padding: 0;}
body{background: #f9f9f9;color: #000;font: 15px Calibri, Arial, sans-serif;text-shadow: 1px 2px 1px #FFFFFF;}
a,a: visited{text-decoration: none;outline: none;color: #fff;}
a: hover{text-decoration: underline;color: #ddd;}
footer{background: #444 url("/jscss/demoimg/201311/bg-footer.png") repeat;position: fixed;width: 100%;height: 70px;bottom: 0;left: 0;color: #fff;text-shadow: 2px 2px #000;-moz-box-shadow: 5px 1px 10px #000;-webkit-box-shadow: 5px 1px 10px #000;box-shadow: 5px 1px 10px #000;}
footer h1{font: 25px/26px Acens;font-weight: normal;left: 50%;margin: 0px 0 0 150px;padding: 25px 0;position: relative;width: 400px;}
footer a.orig,
a.orig: visited{background: url("/jscss/demoimg/201311/demo2.png") no-repeat right top;border: none;text-decoration: none;color: #FCFCFC;font-size: 14px;height: 70px;left: 50%;line-height: 50px;margin: 12px 0 0 -400px;position: absolute;top: 0;width: 250px;}
#clock{position: relative;width: 600px;height: 600px;list-style: none;margin: 20px auto;background: url('/jscss/demoimg/201311/clock.png') no-repeat center;}
#seconds,
#minutes,
#hours{position: absolute;width: 30px;height: 580px;left: 270px;}
#date{text-shadow: 1px 2px 1px #000;position: absolute;top: 365px;color: #fff;right: 140px;font: 30px/36px Acens;font-weight: bold;letter-spacing: 3px;}
#hours{background: url('/jscss/demoimg/201311/hands.png') no-repeat left;z-index: 1000;}
#minutes{background: url('/jscss/demoimg/201311/hands.png') no-repeat center;width: 25px;z-index: 2000;}
#seconds{background: url('/jscss/demoimg/201311/hands.png') no-repeat right;z-index: 3000;}
</style>
</head>
<body>
<script src="/ajaxjs/jquery-1.6.2.min.js"></script>
<script>
$(document).ready(function() {
//markup for the clock		
	var clock = [
		'<ul id="clock">',
		'<li id="date"></li>',
		'<li id="seconds"></li>',
		'<li id="hours"></li>',
		'<li id="minutes"></li>',
		'</ul>'].join('');
//fadein the clock and append it to the body		
  $(clock).fadeIn().appendTo('body');
	//Download by http://www.codefans.net
	//an autoexecuting function that updates the clovk view every second
	//you can also use setInterval (function Clock (){})();
	(function Clock(){
//get the date and time
            var date = new Date().getDate(),//get the current date
	   hours = new Date().getHours(),//get the current hour
             minutes = new Date().getMinutes();	//get the current minute
	   seconds = new Date().getSeconds(),//get the current second
            $("#date").html(date); //show the current date on the clock
	 var hrotate = hours * 30 + (minutes / 2);
	 //i.e 12 hours * 30 = 360 degrees
            $("#hours").css({
		  'transform'	:  'rotate('+ hrotate +'deg)',
		'-moz-transform'	:'rotate('+ hrotate +'deg)',
		'-webkit-transform'	:'rotate('+ hrotate +'deg)'
		  });
	  var mrotate = minutes * 6; //degrees to rotate the minute hand
            $("#minutes").css({
		'transform'	:  'rotate('+ mrotate +'deg)',
		'-moz-transform'	:'rotate('+ mrotate +'deg)',
		'-webkit-transform'	:'rotate('+ mrotate +'deg)'
		  });  
            var srotate = seconds * 6;//for the rotation to reach 360 degrees
	  //i.e 60 seconds * 6 = 360 degrees.
            $("#seconds").css({
		 'transform'	:  'rotate('+ srotate +'deg)',
		'-moz-transform'	:'rotate('+ srotate +'deg)',
		'-webkit-transform'	:'rotate('+ srotate +'deg)'
		  });
           //a call to the clock function after every 1000 miliseconds
	  setTimeout(Clock,1000);
	})();
});
</script>
</body>
</html>


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:21854次
    • 积分:436
    • 等级:
    • 排名:千里之外
    • 原创:21篇
    • 转载:15篇
    • 译文:0篇
    • 评论:3条
    文章分类
    最新评论