Use the CSS3 Transform property to characterize the scale of the clock and the angle of the pointer, as follows:
<metacharset="UTF-8">
<title>title</title>
<styleId="Style">
html{Height100%;}
Body {
width:100%;
height:100%;
margin:0;
Display:-moz-box;
Display:-webkit-box;
Display:box;
-webkit-box-align:center;
-moz-box-align:center;
Box-align:center;
-webkit-box-pack:center;
-moz-box-pack:center;
Box-pack:center;
}
. Clock {
width:200px;
height:200px;
BORDER:4PX solid black;
border-radius:50%;
position:relative;
}
. Clock UL {
width:100%;
height:100%;
position:relative;
margin:0;
padding:0;
}
. Clock ul li {
List-style:none;
Position:absolute;
top:0;
left:99px;
width:2px;
height:5px;
Background:gray;
Transform-origin:center 100px;
}
. Clock ul li:nth-of-type (5n+1) {
left:98px;
width:4px;
height:10px;
Background:black;
}
. hour {
width:8px;
height:60px;
border-radius:4px;
Position:absolute;
left:96px;
top:40px;
Background-color:black;
Transform-origin:center 60px;
box-shadow:0 0 10px Rgba (0,0,0,0.8);
}
. min {
width:6px;
height:70px;
border-radius:3px;
Position:absolute;
left:97px;
top:30px;
Background-color: #2b2b2b;
Transform-origin:center 70px;
box-shadow:0 0 10px Rgba (0,0,0,0.6);
}
. sec {
width:4px;
height:80px;
border-radius:2px;
Position:absolute;
left:98px;
top:20px;
background-color:red;
Transform-origin:center 80px;
box-shadow:0 0 10px Rgba (255,0,0,0.5);
}
. Center {
width:16px;
height:16px;
box-shadow:0 2px 5px Rgba (0,0,0,0.5);
border-radius:50%;
Position:absolute;
left:92px;
top:92px;
Background-image:radial-gradient (White,gray);
}
</style>
<body>
<p class= "Clock" >
<ul id= "TickBox" >
</ul>
<p class= "Hour" id= "Hour" ></p>
<p class= "min" id= "min" ></p>
<p class= "SEC" id= "SEC" ></p>
<p class= "center" ></p>
</p>
<script>
Window.onload = function () {
var Oul = document.getElementById ("TickBox");
var ostyle = document.getElementById ("style");
var listr = "";
var stylestr = "";
for (Var i=0;i<60;i++) {
Stylestr + = '. Clock ul li:nth-of-type (' + (i+1) + ') {transform:rotate (' +i*6+ ' deg);} ';
Listr + = ' <li></li> ';
}
ostyle.innerhtml + = Stylestr;
oul.innerhtml = Listr;
var ohour = document.getElementById ("Hour");
var omin = document.getElementById ("min");
var oSec = document.getElementById ("SEC");
function GetTime () {
var timer = new Date ();
var sec = Timer.getseconds ();
var min = timer.getminutes ();
var hour = timer.gethours ();
var TranS = sec*360/60;
var tranm = (min+sec/60) *360/60;
var Tranh = (hour + min/60) *360/12;
OSec.style.transform = ' rotate (' +trans+ ' deg) Translatez ( -1px) ';
OMin.style.transform = ' rotate (' +tranm+ ' deg) Translatez ( -1px) ';
OHour.style.transform = ' rotate (' +tranh+ ' deg) Translatez ( -1px) ';
}
SetInterval (gettime,1000);
GetTime ();
}
</script>
</body>