麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > JavaScript > 正文

CSS+jQuery實現的一個放大縮小動畫效果

2019-11-20 21:57:01
字體:
來源:轉載
供稿:網友
今天幫朋友寫了一些代碼,自己覺得寫著寫著,好幾個版本以后,有點滿意,于是就貼出來。
都是定死了的。因為需求就只有4個元素。如果是要用CSS的class來處理,那就需要用到CSS3動畫了。
復制代碼 代碼如下:

<!DOCTYPE html>
<html>
<head>
<title> CSS+jQuery動畫效果 </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(){
// 增長
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">第一頁</button>
<button id="button2">第2頁</button>
<button id="button3">第3頁</button>
<button id="button4">第4頁</button>
</div>
</body>
</html>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲成人精品在线 | 91精品国产综合久久婷婷香蕉 | 中国a毛片 | 一区在线免费视频 | 久热久操 | 人人做人人看 | 91在线免费观看 | 亚洲综合一区在线观看 | 黄色免费在线视频网站 | 国产精品av久久久久久网址 | 蝌蚪久久窝 | 久久毛片免费 | 久色免费视频 | 草操影院| 49vv看片免费 | 免费久久精品 | 91精品国产综合久久婷婷香 | 露脸各种姿势啪啪的清纯美女 | 俄罗斯16一20sex牲色另类 | 亚洲精品久久久久www | 九九热视频免费观看 | 天天黄色片 | 一级视频在线播放 | 一级毛片电影院 | 久久免费视频5 | 欧美福利视频一区二区三区 | 性视频久久 | 亚洲精品一区二区三区免 | 国产一区在线视频观看 | 欧美激情精品久久久久久黑人 | 男女羞羞的视频 | www国产成人免费观看视频,深夜成人网 | 国产一级爱c视频 | 污在线观看网站 | 久久精精 | 亚洲婷婷日日综合婷婷噜噜噜 | 高清视频一区二区 | 亚洲国产高清视频 | 国产精品久久久久一区二区 | 国产一区精品在线观看 | 中文字幕综合在线观看 |