DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jquery模仿時鐘秒針走動
jquery模仿時鐘秒針走動
編輯:JQuery特效代碼     
先看效果:


代碼如下:
<!DOCTYPE html>
<html>
<head>
<style>
.framehovertree {
position: relative;
height: 410px;
width: 410px;
margin: 100px;
border: 1px solid black;
border-radius:50%;
}

.centerhovertree {
height:200px;
width:4px;
position: absolute;
border: 0px solid black;
background-color: yellow;
transform: rotate(90deg);
transform-origin: 50% 100%;
border-radius:2px;
z-index:99999
}

.smallhovertree {
width: 10px;
height: 10px;
background-color: hotpink;
position: absolute;
border-radius: 50%;
z-index: 999;
}
</style>
<script src="http://hovertree.com/ziyuan/jquery/jquery-1.11.3.min.js"></script>
</head>

<body>

<div id="div1" class="framehovertree"><div class="smallhovertree"></div>
<div id="div2" class="centerhovertree"></div>

</div>
<script>
$(function () {
var centerDiv = $(".centerhovertree"), frameDiv = $(".framehovertree")
$(".centerhovertree").css({ "left": (frameDiv.width() - centerDiv.width()) / 2, "top": (frameDiv.height() / 2 - centerDiv.height()) })

var smallhovertree = $(".smallhovertree")
$(".smallhovertree").css({ "left": (frameDiv.width() - smallhovertree.width()) / 2, "top": (frameDiv.height() - smallhovertree.height()) / 2 })

})
var h_deg = 0;
function clock() {
document.querySelector(".centerhovertree").style.transform = "rotate(" + ((new Date().getSeconds()) * 6) + "deg)";
}
var int = self.setInterval("clock()", 50)

</script>
</body>
</html>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved