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);
});
});
第一页
第2页
第3页
第4页
html动画效果放大,一个CSS+jQuery实现的放大缩小动画效果相关推荐
- HTML css jQuery实现导航栏(华丽动画)
<!DOCTYPE html> <html><head><meta charset="utf-8" /><title>H ...
- html首行字放大标签,CSS设置首字放大
CSS设置首字放大 在很多的文章中,都有一个首字放大的效果,在CSS中同样可以实现该效果. CSS中通过对第一个字,进行单独的设置从而实现该效果. 首字放大 中秋节是远古天象崇拜--敬月习俗的遗痕.据 ...
- css怎么动画中该透明度,CSS如何实现透明度变化的动画
CSS如何实现透明度变化的动画 发布时间:2020-10-19 15:55:49 来源:亿速云 阅读:73 作者:小新 这篇文章将为大家详细讲解有关CSS如何实现透明度变化的动画,小编觉得挺实用的,因 ...
- html鼠标滚动效果代码,JS+CSS实现大气清新的滑动菜单效果代码
本文实例讲述了JS+CSS实现大气清新的滑动菜单效果代码.分享给大家供大家参考,具体如下: 这是一款比较大气清新的滑动导航菜单,CSS和JavaScript配合完成,鼠标放到一级菜单上,会滑出二级的菜 ...
- html动画爱心制作代码,CSS心形加载的动画源码的实现
废话不多说上代码,代码很简答,研究一下就明白了,有不明白的可以问我. .heart-loading { margin-top: 120px; width: 200px; height: 200px; ...
- HTML+CSS+jquery代码实例:水波纹效果与纯HTML CSS和jquery(拿来就能用)
效果: 代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <t ...
- html文字简单动画效果,CSS3一个简单的按钮悬停波浪文本动画效果
CSS 语言: CSSSCSS 确定 @import url("https://fonts.googleapis.com/css?family=Roboto:900"); body ...
- html+css+jquery 实现超帅留言墙效果!超帅,不喜勿喷!
效果图: 预览地址:https://ktblog.top/html/msg.html 下载地址:https://ktblog.top/jie/detail/39893ae50a084bac969
- html如何有立体效果,一段CSS代码让div盒子有立体效果
先上效果图,再来代码: 上图是对一个336*280px大小的矩形进行了调整,给它增加了一个投影的效果,就好像它立了起来,有种立体的感觉,怎么做到的呢?其实也就是一段CSS的功夫.先确定下html结构, ...
最新文章
- 输入今天是星期几的序号,给今天和昨天赋予枚举值,并输出昨天是星期几的枚举值
- 线程队列 线程池 协程
- geth 以太坊钱包_以太坊Geth节点RPC API中文文档
- Windows消息机制-PreTranslateMessage
- Js获取当前页面URL各种参数
- 上传文件的加密和下载文件解密
- spark 读取elasticsearch数据
- nginx学习笔记之安装
- 如果有一个工具可以帮助你将你的代码可视化,你需要吗?
- Thinking in java Java编程思想 该不该读
- paypal java sdk_PayPal-Java SDK /信用卡付款问题
- 微信公众号推文怎么做?
- Python将二维数组/多维数组转换为一维
- 编写算法将二叉树中所有结点的左、右子树相互交换
- C语言--小学生计算机辅助教学系统
- 贝壳云P1刷机记录(5.10内核Armbian)
- eax,ebx,ecx,edx,esi,edi,ebp,esp寄存器的作用
- ETL为什么经常变成ELT甚至LET?
- 红米手机怎么把软件移到sd卡
- ie8与ie9的区别