利用JavaScript实现网页时钟,效果如下图所示:
首先在body中完成表盘、指针的资源载入:
<div><img src="../../image/clockface.jpg" alt=""></div>
<hr id="hour" >
<hr id="min">
<hr id="second">
设置CSS样式:
<style>
body{
margin: 0;
}
div{
margin: 0 auto;
width: 600px;
height: 600px;
}
#hour{
background-color: black;
width: 130px;
height: 10px;
position: fixed;
top: 295px;
left: 50%;
margin-left: -65px