Jquery 一起淡化和缩放
Jquery fade and scale together
我有这个代码:https://jsfiddle.net/og248ev0/
<div class="a"></div>
<div class="a"></div>
当顶部 div 淡出时,第二个 div 跳到它上面的位置。 (如预期)
我怎样才能让 after 顶部 div 淡出,第二个 div animates 向上,不只是跳跃?
谢谢
编辑:
我有另一个版本的文字:
https://jsfiddle.net/og248ev0/7/
这里的问题是第二个项目 'jumps' 和动画因为底边距而结束。
我可以解决这个问题吗?
您可以将 animate()
分别用于 opacity
和 height
。默认情况下,动画是排队的。所以第二个将在第一个之后工作。
$('.a').eq(0)
.animate({
opacity: 0
}, 1000)
.animate({
height: 0,
marginBottom:0 //to get rid of the final jump because of margin
}, 1000);
.a {
width: 100px;
height: 50px;
background: red;
margin-bottom: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="a"></div>
<div class="a"></div>
我有这个代码:https://jsfiddle.net/og248ev0/
<div class="a"></div>
<div class="a"></div>
当顶部 div 淡出时,第二个 div 跳到它上面的位置。 (如预期)
我怎样才能让 after 顶部 div 淡出,第二个 div animates 向上,不只是跳跃?
谢谢
编辑:
我有另一个版本的文字:
https://jsfiddle.net/og248ev0/7/
这里的问题是第二个项目 'jumps' 和动画因为底边距而结束。
我可以解决这个问题吗?
您可以将 animate()
分别用于 opacity
和 height
。默认情况下,动画是排队的。所以第二个将在第一个之后工作。
$('.a').eq(0)
.animate({
opacity: 0
}, 1000)
.animate({
height: 0,
marginBottom:0 //to get rid of the final jump because of margin
}, 1000);
.a {
width: 100px;
height: 50px;
background: red;
margin-bottom: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="a"></div>
<div class="a"></div>