日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > CSS >内容正文

CSS

html动画效果放大,一个CSS+jQuery实现的放大缩小动画效果

發布時間:2024/4/13 CSS 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html动画效果放大,一个CSS+jQuery实现的放大缩小动画效果 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

今天幫朋友寫了一些代碼,自己覺得寫著寫著,好幾個版本以后,有點滿意,于是就貼出來。

都是定死了的。因為需求就只有4個元素。如果是要用CSS的class來處理,那就需要用到CSS3動畫了。

功能 : 在上方的按鈕上滑動,可以切換各個page,點擊下方的各個page,也可以切換收縮還是展開狀態。

?

初始效果預覽

CSS+jQuery動畫效果

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;

}

$(function(){

// 增長

function increase($div,e){

var expstatus = $div.data("expstatus");

if(!expstatus){

// 沒有展開過

$div.data("expstatus","yes");

}

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","");

});

//

var expstatus1 = $page1.data("expstatus");

if(expstatus1){

$page1.data("expstatus",null);

}

var expstatus2 = $page2.data("expstatus");

if(expstatus2){

$page2.data("expstatus",null);

}

var expstatus3 = $page3.data("expstatus");

if(expstatus3){

$page3.data("expstatus",null);

}

var expstatus4 = $page4.data("expstatus");

if(expstatus4){

$page4.data("expstatus",null);

}

if(e){

e.stopPropagation();

return false;

} else {

return true;

}

};

//

$("#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);

});

// 新的

$(".pages").unbind("click touchstart").bind("click touchstart",function(e){

//

var $this = $(this);

var expstatus = $this.data("expstatus");

if(!expstatus){

// 沒有展開過

//

return increase($this,e);

} else {

return resize(e);

}

});

//

$("body").click(function(e){

// 所有的都移除

return resize(null);

});

});

page1page2page3page4

第一頁

第2頁

第3頁

第4頁

總結

以上是生活随笔為你收集整理的html动画效果放大,一个CSS+jQuery实现的放大缩小动画效果的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。