jQuery+css3實(shí)現(xiàn)轉(zhuǎn)動(dòng)的正方形效果(附demo源碼下載)
本文實(shí)例講述了jQuery+css3實(shí)現(xiàn)轉(zhuǎn)動(dòng)的正方形效果。分享給大家供大家參考,具體如下:
主要是應(yīng)用到了css3中的rotate來控制旋轉(zhuǎn)角度
運(yùn)行效果截圖如下:

點(diǎn)擊此處查看在線演示效果。
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<style type="text/css" >
img { width:50px; height:50px; }
.margin1 { margin-top:50px; margin-left:100px; }
.margin2 { margin-top:50px; margin-left:100px; }
.margin3 { margin-top:50px; margin-left:100px; }
.margin4 { margin-top:50px; margin-left:100px; }
.margin5 { margin-top:50px; margin-left:100px; }
.margin6 { margin-top:50px; margin-left:175px; }
.margin7 { margin-top:50px; margin-left:100px; }
.margin8 { margin-top:50px; margin-left:100px; }
.margin9 { margin-top:50px; margin-left:100px; }
.margin10 { margin-top:50px; margin-left:250px; }
.margin11 { margin-top:50px; margin-left:100px; }
.margin12 { margin-top:50px; margin-left:100px; }
.margin13 { margin-top:50px; margin-left:325px; }
.margin14 { margin-top:50px; margin-left:100px; }
.margin15 { margin-top:50px; margin-left:400px; }
</style>
<script type="text/javascript" >
var ADD_ANGLE = 45; // 每次偏移角度
var angle = 0; // 角度
window.onload = function () {
var img = $("img");
setInterval(function () {
rotate(img);
}, 50);
}
function rotate(obj) {
angle += ADD_ANGLE;
if (angle == 360) {
angle = 0;
}
obj.css({ "transform": "rotate(" + angle + "deg)", "-webkit-transform": "rotate(" + angle + "deg)", "-moz-transform": "rotate(" + angle + "deg)" });
}
</script>
</head>
<body>
<img src="3.jpg" alt="" class="margin1" />
<img src="3.jpg" alt="" class="margin2" />
<img src="3.jpg" alt="" class="margin3" />
<img src="3.jpg" alt="" class="margin4" />
<img src="3.jpg" alt="" class="margin5" />
<br />
<img src="3.jpg" alt="" class="margin6" />
<img src="3.jpg" alt="" class="margin7" />
<img src="3.jpg" alt="" class="margin8" />
<img src="3.jpg" alt="" class="margin9" />
<br />
<img src="3.jpg" alt="" class="margin10" />
<img src="3.jpg" alt="" class="margin11" />
<img src="3.jpg" alt="" class="margin12" />
<br />
<img src="3.jpg" alt="" class="margin13" />
<img src="3.jpg" alt="" class="margin14" />
<br />
<img src="3.jpg" alt="" class="margin15" />
</body>
</html>
完整實(shí)例代碼點(diǎn)擊此處本站下載。
更多關(guān)于jQuery特效相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常見經(jīng)典特效匯總》及《jQuery動(dòng)畫與特效用法總結(jié)》。
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jQuery+css實(shí)現(xiàn)的時(shí)鐘效果(兼容各瀏覽器)
- jquery+css3實(shí)現(xiàn)會(huì)動(dòng)的小圓圈效果
- jQuery+css實(shí)現(xiàn)的換頁標(biāo)簽欄效果
- jQuery+CSS實(shí)現(xiàn)滑動(dòng)的標(biāo)簽分欄切換效果
- jquery+css實(shí)現(xiàn)動(dòng)感的圖片切換效果
- jQuery+CSS3實(shí)現(xiàn)3D立方體旋轉(zhuǎn)效果
- jQuery+CSS3折疊卡片式下拉列表框?qū)崿F(xiàn)效果
- jQuery+css實(shí)現(xiàn)的藍(lán)色水平二級(jí)導(dǎo)航菜單效果代碼
- jquery+CSS3模擬Path2.0動(dòng)畫菜單效果代碼
- jQuery+css實(shí)現(xiàn)炫目的動(dòng)態(tài)塊漂移效果
相關(guān)文章
jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)ToolTip元素定位顯示功能,結(jié)合實(shí)例形式分析了jQuery針對(duì)頁面元素屬性的動(dòng)態(tài)操作相關(guān)技巧,需要的朋友可以參考下2016-11-11
25個(gè)非常棒的jQuery滑塊插件和教程小結(jié)
圖像滑塊和幻燈片效果,已成為網(wǎng)頁設(shè)計(jì)的基本要素。它們以有趣的方式展示視覺內(nèi)容。如果你一直想知道這是如何實(shí)現(xiàn)的,那么這里的25個(gè)非常棒的 jQuery 圖片滑塊制作教程將幫助您實(shí)現(xiàn)這種效果2011-09-09
深入理解jQuery中l(wèi)ive與bind方法的區(qū)別
本篇文章主要是對(duì)jQuery中l(wèi)ive與bind方法的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-12-12
jquery實(shí)現(xiàn)文本框數(shù)量加減功能的例子分享
在做商城項(xiàng)目的時(shí)候,需要在購物車中增加一個(gè)商品加減功能,并在加減時(shí)同時(shí)修改總價(jià)格的顯示,并且保證文本框text只能輸入純數(shù)字2014-05-05
Jquery中g(shù)etJSON在asp.net中的使用說明
Jquery中g(shù)etJSON在asp.net中的使用說明,需要的朋友可以參考下。2011-03-03

