Blogger Information
Blog 27
fans 0
comment 0
visits 22430
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
钟表-第五期0413作业
不乖的博客
Original
782 people have browsed it

实例

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.clock{
				width:600px ;
				height: 600px;
				background: url(images/clock.jpg) no-repeat;
				background-size: 100% 100%;
				margin: 50px auto;
				position: relative;
			}
			.hour{
				width: 100%;
				height: 100%;
				background: url(images/hour.png) no-repeat center center;
				position: absolute;
			}
			.minute{
				width: 100%;
				height: 100%;
				background: url(images/minute.png) no-repeat center center;
				position: absolute;
			}
			.second{
				width: 100%;
				height: 100%;
				background: url(images/second.png) no-repeat center center;
				position: absolute;
			}
		</style>
	</head>
	<body>
		<div class="clock" id="clock">
			<div class="hour"></div>
			<div class="minute"></div>
			<div class="second"></div>
		</div>
		<script>
			show();
			function show(){
				var clock = document.getElementById('clock');
				var now = new Date();
				var hour = now.getHours();
				var minute = now.getMinutes();
				var second = now.getSeconds();
				console.log(hour+':'+minute+':'+second);
				clock.children[0].style.transform = "rotate("+hour*30+"deg)";
				clock.children[1].style.transform = "rotate("+minute*6+"deg)";
				clock.children[2].style.transform = "rotate("+second*6+"deg)";
			}
			setInterval(show,1000);
		</script>
	</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post