jQuery+css3網頁時鐘效果

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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章