博客列表 >jq delay() 延迟动画

jq delay() 延迟动画

kong
kong原创
2018年04月11日 22:14:441452浏览

先引入本地jq库,

鼠标经过效果:

若水GIF截图_2018年4月18日22点24分43秒.gif



<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>delay()动画延迟 </title>
</head>
<body>
<style>

*,ul{
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
ul{
list-style-type: none;
}
.box{
width: 900px;
overflow: hidden;
margin: 100px auto;
padding: 10px;
background: #000;
}
.box ul{
overflow: hidden;
}
.box ul li{
float: left;
width: 280px;
height: 280px;
margin-left: 10px;
background: #000;
position: relative;
}
.box ul li span{
position: absolute;
}
.top,.bottom{
/*width: 100%;*/
border-bottom: 1px solid blue;
}
.top{
top: 0;
right: 0;
}
.bottom{
bottom: 0;
left: 0;
}
.left,.right{
/*height: 100%;*/
border-left: 1px solid blue;
}
.left{
top: 0;
left: 0;
}
.right{
right: 0;
bottom: 0;
}


</style>

<div>
<ul>
<li>
<span></span>
<span></span>
<span></span>
<span></span>
</li>
<li>
<span></span>
<span></span>
<span></span>
<span></span>
</li>
<li>
<span></span>
<span></span>
<span></span>
<span></span>
</li>
</ul>
</div>
</body>
<script src="jquery.min.js"></script>
<script>
$(".box li").hover(function(){
$(this).children('.top').delay(600).stop(true).animate({
"width": "100%"
},400).siblings('.left').delay(1000).stop(true).animate({
"height": "100%"
},400).siblings('.bottom').delay(600).stop(true).animate({
"width": "100%"
},400).siblings('.right').delay(1000).stop(true).animate({
"height": "100%"
},400)
},function(){
$(this).children('.top').delay(600).stop(true).animate({
"width": "0"
},400).siblings('.left').delay(1000).stop(true).animate({
"height": "0"
},400).siblings('.bottom').delay(600).stop(true).animate({
"width": "0"
},400).siblings('.right').delay(1000).stop(true).animate({
"height": "0"
},400)
})
</script>
</html>


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议