1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > CSS+jQuery实现的一个放大缩小动画效果【jquery】

CSS+jQuery实现的一个放大缩小动画效果【jquery】

时间:2021-02-18 10:25:46

相关推荐

CSS+jQuery实现的一个放大缩小动画效果【jquery】

web前端|js教程

jQuery+CSS,放大缩小动画

web前端-js教程

今天帮朋友写了一些代码,自己觉得写着写着,好几个版本以后,有点满意,于是就贴出来。

都是定死了的。因为需求就只有4个元素。如果是要用CSS的class来处理,那就需要用到CSS3动画了。

poi源码下载,vscode看html,ubuntu dji,tomcat健康检测,c 修改sqlite表列数,阿里云oss插件,前端数据统计图框架,爬虫如何提取采集数据,php 上传乱码,seo虚拟资源项目,dedecms手机网站模板,源码网页广告,模板无忧源码lzw

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

});

});

page1

page2

page3

page4

php红娘婚恋交友网源码,vscode 需要收费吗,ubuntu建立wifi,打开tomcat的猫,sqlite数据库操作c,爬虫个人需要承担责任吗,php 完美类,茶语网seo部门,dj音乐网站源码,angulr模板lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。