CSS+jQuery實(shí)現(xiàn)的一個(gè)放大縮小動(dòng)畫效果
都是定死了的。因?yàn)樾枨缶椭挥?個(gè)元素。如果是要用CSS的class來處理,那就需要用到CSS3動(dòng)畫了。
<!DOCTYPE html>
<html>
<head>
<title> CSS+jQuery動(dòng)畫效果 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="鐵錨">
<style>
body{
z-index: 0;
width: 100%;
min-height: 400px;
}
.pages{
position: absolute;
}
.current{
position: absolute;
z-index: 12 !important;
left: 0px !important;
}
.page1{
background-color: #a5cfff;
z-index: 1;
width: 300px;
height:280px;
top: 100px;
left: 0px;
}
.page2{
background-color: #b1ca54;
z-index: 2;
width: 250px;
height:270px;
top: 160px;
left: 0px;
}
.page3{
background-color: #c2c6c9;
z-index: 3;
width: 200px;
height:260px;
top: 220px;
left: 0px;
}
.page4{
background-color: #ef9e9c;
z-index: 4;
width: 150px;
height:250px;
top: 250px;
left: 0px;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
// 增長(zhǎng)
function increase($div,e){
var style = $div.attr("style");
$div.addClass("current").attr("styleold",style);
//
$div.stop();
$div.animate({
opacity:0.9,
width:"400px",
height: "400px",
top: "100px",
left: "0px"
},600)
.animate({
opacity:1.0
},30);
e.stopPropagation();
return false;
};
// 還原
function resize(e){
// 所有的都移除
var $page1 = $(".current.page1") ;
$page1.stop();
$page1.animate({
opacity:1.0,
width:"300px",
height: "280px",
top: "100px",
left: "0px"
},600,null,function(){
$page1.removeClass("current").attr("style","");
});
var $page2 = $(".current.page2") ;
$page2.stop();
$page2.animate({
opacity:1.0,
width:"250px",
height: "270px",
top: "160px",
left: "0px"
},600,null,function(){
$page2.removeClass("current").attr("style","");
});
var $page3 = $(".current.page3") ;
$page3.stop();
$page3.animate({
opacity:1.0,
width:"200px",
height: "260px",
top: "220px",
left: "0px"
},600,null,function(){
$page3.removeClass("current").attr("style","");
});
var $page4 = $(".current.page4") ;
$page4.stop();
$page4.animate({
opacity:1.0,
width:"150px",
height: "250px",
top: "250px",
left: "0px"
},600,null,function(){
$page4.removeClass("current").attr("style","");
});
e.stopPropagation();
return false;
};
//
$("#button1").unbind("mouseover").bind("mouseover",function(e){
//
var $page1 = $(".page1");
// 添加特定的
return increase($page1,e);
}).unbind("mouseout").bind("mouseout",function(e){
return resize(e);
});
//
$("#button2").unbind("mouseover").bind("mouseover",function(e){
//
var $page2 = $(".page2");
// 添加特定的
return increase($page2,e);
}).unbind("mouseout").bind("mouseout",function(e){
return resize(e);
});
//
$("#button3").unbind("mouseover").bind("mouseover",function(e){
//
var $page3 = $(".page3");
// 添加特定的
return increase($page3,e);
}).unbind("mouseout").bind("mouseout",function(e){
return resize(e);
});
//
$("#button4").unbind("mouseover").bind("mouseover",function(e){
//
var $page4 = $(".page4");
// 添加特定的
return increase($page4,e);
}).unbind("mouseout").bind("mouseout",function(e){
return resize(e);
});
//
$(".pages").unbind("mouseover").bind("mouseover",function(e){
//
var $this = $(this);
// 添加特定的
return increase($this,e);
}).unbind("mouseout").bind("mouseout",function(e){
// 所有的都移除
return resize(e);
});
//
$("body").click(function(e){
// 所有的都移除
return resize(e);
});
});
</script>
</head>
<body>
<div class="pages page1">page1</div>
<div class="pages page2">page2</div>
<div class="pages page3">page3</div>
<div class="pages page4">page4</div>
<div style="background-color: #a5cfff;">
<button id="button1">第一頁(yè)</button>
<button id="button2">第2頁(yè)</button>
<button id="button3">第3頁(yè)</button>
<button id="button4">第4頁(yè)</button>
</div>
</body>
</html>
- 基于Jquery和html5實(shí)現(xiàn)炫酷的3D焦點(diǎn)圖動(dòng)畫
- jquery+html5爛漫愛心表白動(dòng)畫代碼分享
- jQuery結(jié)合HTML5制作的愛心樹表白動(dòng)畫
- jQuery實(shí)現(xiàn)加入購(gòu)物車飛入動(dòng)畫效果
- jQuery實(shí)現(xiàn)圖像旋轉(zhuǎn)動(dòng)畫效果
- JQuery動(dòng)畫和停止動(dòng)畫實(shí)例代碼
- Jquery中使用show()與hide()方法動(dòng)畫顯示和隱藏圖片
- jQuery下的動(dòng)畫處理總結(jié)
- 基于jquery的direction圖片漸變動(dòng)畫效果
- jQuery+HTML5實(shí)現(xiàn)WebGL高性能煙花綻放動(dòng)畫效果【附demo源碼下載】
相關(guān)文章
jQuery實(shí)現(xiàn)數(shù)字自動(dòng)增加或者減少的動(dòng)畫效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)數(shù)字自動(dòng)增加或者減少的動(dòng)畫效果,涉及jQuery結(jié)合時(shí)間函數(shù)動(dòng)態(tài)設(shè)置元素屬性相關(guān)操作技巧,需要的朋友可以參考下2018-12-12jquery ajax實(shí)現(xiàn)下拉框三級(jí)無刷新聯(lián)動(dòng),且保存保持選中值狀態(tài)
jquery ajax實(shí)現(xiàn)下拉框三級(jí)無刷新聯(lián)動(dòng),且保存保持選中值狀態(tài)。需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-10-10jQuery移動(dòng)端跑馬燈抽獎(jiǎng)特效升級(jí)版(抽獎(jiǎng)概率固定)實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery移動(dòng)端跑馬燈抽獎(jiǎng)特效升級(jí)版(抽獎(jiǎng)概率固定)實(shí)現(xiàn)方法,涉及jQuery數(shù)值運(yùn)算及條件判斷等相關(guān)操作技巧,需要的朋友可以參考下2019-01-01JQuery組件基于Bootstrap的DropDownList(完整版)
這篇文章主要介紹了JQuery組件基于Bootstrap的DropDownList的完整版,在原有基礎(chǔ)上進(jìn)行完善功能,感興趣的小伙伴們可以參考一下2016-07-07Jquery 選中表格一列并對(duì)表格排序?qū)崿F(xiàn)原理
該實(shí)現(xiàn)的主要思想是:獲取鼠標(biāo)點(diǎn)擊的表頭單元格的列號(hào),遍歷數(shù)據(jù)行,獲取每個(gè)<tr>中的html,同時(shí)獲取每個(gè)<tr>標(biāo)簽下對(duì)應(yīng)獲取到的列號(hào)的<td>標(biāo)簽中的內(nèi)容,并取得<th>標(biāo)簽的type屬性值,需要的朋友可以了解下2012-12-12jQuery聯(lián)動(dòng)日歷的實(shí)例解析
本篇文章主要對(duì)jQuery聯(lián)動(dòng)日歷的實(shí)例進(jìn)行解析說明。有興趣的朋友可以下載源碼調(diào)試運(yùn)行試試看,希望對(duì)大家有所幫助2016-12-12jQuery操作iframe中js函數(shù)的方法小結(jié)
這篇文章主要介紹了jQuery操作iframe中js函數(shù)的方法,結(jié)合實(shí)例形式總結(jié)分析了jQuery操作iframe中的元素、函數(shù)常用方法與注意事項(xiàng),具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-07-07