jQuery實(shí)現(xiàn)圖像旋轉(zhuǎn)動(dòng)畫(huà)效果
廢話(huà)不多說(shuō)了,直接給大家貼代碼了,具體代碼如下所示:
<!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>jQuery Animation - fadeTo </title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div[name='divPop']").bind("click",clickMove).bind("dblclick",forward);
})
function clickMove(){
var left = $(this).css("left");
if(left == "350px"){
loginMove("right",2);
}
else if(left == "150px"){
loginMove("right",1);
}
else if(left == "455px"){
loginMove("right",3);
}
else if(left == "650px"){
loginMove("left",1);
}
else if(left == "530px"){
loginMove("left",2);
}
else{
var cla = $(this).attr("class");
switch (cla) {
case "login_1": forward("http://www.baidu.com/");break;
case "login_2": forward("http://www.google.cn/");break;
case "login_3": forward("http://www.163.com/");break;
case "login_4": forward("http://www.sina.com.cn/");break;
case "login_5": forward("http://www.sohu.com/");break;
case "login_6": forward("http://www.qq.com/");break;
default: forward('#');
}
}
}
function loginMove(direction,index){ //動(dòng)畫(huà)函數(shù)
var timerId;
if(index<=0){
clearInterval(timerId); //取消動(dòng)畫(huà)功能
return;
}
var div = $("[name='divPop']"); //取得所有div
var divdivLength = div.length;
if(direction=="left"){
div[-1] = div[divLength-1]
var n=-2;
}
else{
div[divLength] = div[0];
var n = 0;
}
div.each(function(){ //jquery封裝的動(dòng)畫(huà)功能
++n;
$(this).animate(
{
"top":$(div[n]).css("top"), //取得下一個(gè)目標(biāo)位置div的參數(shù)
"left":$(div[n]).css("left"),
"width":$(div[n]).width(),
"height":$(div[n]).height()
},
600,
function(){
if($(this).css("top")=='150px'){
$(this).css({zIndex:3}); //設(shè)置圖層置頂
}
else if ($(this).css("top")=='170px'){
$(this).css({zIndex:2});
}
else if ($(this).css("top")=='80px'){
$(this).css({zIndex:1});
}
else {
$(this).css({zIndex:0});
}
}
);
})
timerId = setInterval(function(){
loginMove(direction,--index);
},650);
}
function forward(url){
window.location.href = url;
}
</script>
</head>
<body>
<div name="divPop" class="login_1" style="background-color:#f0f0f0;border:solid 1px ;cursor:pointer; width:355px; height:343px; position:absolute; left:330px; top:150px; z-index:3; filter:alpha(opacity=90);">
<div style="text-align:center;">百度</div>
</div>
<div name="divPop" class="login_2" style="background-color:blue;border:solid 1px;cursor:pointer; width:220px; height:230px; position:absolute; left:650px; top:170px; z-index:2; filter:alpha(opacity=90);">
<div style="text-align:center;">Google</div>
</div>
<div name="divPop" class="login_3" style="background-color:yellow;border:solid 1px;cursor:pointer; width:136px; height:130px; position:absolute; left:530px; top:80px; z-index:1; filter:alpha(opacity=90); ">
<div style="text-align:center;">網(wǎng)易</div>
</div>
<div name="divPop" class="login_4" style="background-color:red;border:solid 1px;cursor:pointer; width:105px; height:100px; position:absolute; left:455px; top:50px; z-index:0; filter:alpha(opacity=90); ">
<div style="text-align:center;">新浪</div>
</div>
<div name="divPop" class="login_5" style="background-color:#00ff00;border:solid 1px;cursor:pointer; width:136px; height:130px; position:absolute; left:350px; top:80px; z-index:1; filter:alpha(opacity=90); ">
<div style="text-align:center;font:write">阿里巴巴</div>
</div>
<div name="divPop" class="login_6" style="background-color:green;border:solid 1px;cursor:pointer; width:220px; height:230px; position:absolute; left:150px; top:170px; z-index:2; filter:alpha(opacity=90); ">
<div style="text-align:center;font:write">騰訊</div>
</div>
</body>
</html>
以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)圖像旋轉(zhuǎn)動(dòng)畫(huà)效果,希望對(duì)大家有所幫助!
- 用js實(shí)現(xiàn)的模擬jquery的animate自定義動(dòng)畫(huà)(2.5K)
- 深入理解jquery自定義動(dòng)畫(huà)animate()
- jQuery中使用animate自定義動(dòng)畫(huà)的方法
- Jquery 自定義動(dòng)畫(huà)概述及示例
- jQuery自定義動(dòng)畫(huà)函數(shù)實(shí)例詳解(附demo源碼)
- jQuery使用動(dòng)畫(huà)隊(duì)列自定義動(dòng)畫(huà)操作示例
- jQuery動(dòng)畫(huà)animate方法使用介紹
- jquery animate 動(dòng)畫(huà)效果使用說(shuō)明
- JQuery動(dòng)畫(huà)animate的stop方法使用詳解
- 分享8款優(yōu)秀的 jQuery 加載動(dòng)畫(huà)和進(jìn)度條插件
- Jquery中使用show()與hide()方法動(dòng)畫(huà)顯示和隱藏圖片
- jQuery三組基本動(dòng)畫(huà)與自定義動(dòng)畫(huà)操作實(shí)例總結(jié)
相關(guān)文章
完美兼容各大瀏覽器的jQuery仿新浪圖文淡入淡出間歇滾動(dòng)特效
本文是作者學(xué)習(xí)jQuery之后練手之作,兼容各大瀏覽器,非常的精美實(shí)用,這里放出來(lái)給小伙伴們,有需要的直接拿走,別跟我客氣^_^2014-11-11
jQuery中的read和JavaScript中的onload函數(shù)的區(qū)別
這篇文章主要介紹了jQuery中的read和JavaScript中的onload函數(shù)的區(qū)別,這兩個(gè)函數(shù)在web編程中是最常用的,一定要搞清楚它們的區(qū)別,需要的朋友可以參考下2014-08-08
模擬jQuery ajax服務(wù)器端與客戶(hù)端通信的代碼
本案例通過(guò)jQuery和Servlet技術(shù)來(lái)判斷用戶(hù)名是否存在,讓讀者明白jQuery是怎么調(diào)用服務(wù)器后臺(tái)的。還給出了解決中文亂碼的方案和如何避免各種瀏覽器的緩存。2011-03-03
Jquery原生態(tài)實(shí)現(xiàn)表格header頭隨滾動(dòng)條滾動(dòng)而滾動(dòng)
表頭是浮動(dòng)的,因?yàn)閮?nèi)容在同一頁(yè)面展示,當(dāng)滾動(dòng)時(shí),看不到列頭,為了改動(dòng)少只能使用jquery原生態(tài)實(shí)現(xiàn)滾動(dòng)2014-03-03
JQuery實(shí)現(xiàn)的圖文自動(dòng)輪播效果插件
這篇文章主要介紹了JQuery實(shí)現(xiàn)的圖文自動(dòng)輪播效果插件,涉及jQuery處理鼠標(biāo)事件及動(dòng)畫(huà)效果的方法,需要的朋友可以參考下2015-06-06
淺析jQuery對(duì)select操作小結(jié)(遍歷option,操作option)
本篇文章是關(guān)于jQuery對(duì)select的操作進(jìn)行了總結(jié)介紹,需要的朋友可以參考下2013-07-07
jQuery實(shí)現(xiàn)可以控制圖片旋轉(zhuǎn)角度效果(附demo源碼下載)
這篇文章主要介紹了jQuery實(shí)現(xiàn)可以控制圖片旋轉(zhuǎn)角度效果,可實(shí)現(xiàn)通過(guò)下方的滑塊拖動(dòng)控制圖片旋轉(zhuǎn)的功能,涉及jQuery操作頁(yè)面元素樣式動(dòng)態(tài)變換的技巧,并附帶demo源碼供讀者下載,需要的朋友可以參考下2016-01-01

