【发布时间】:2015-11-14 18:59:33
【问题描述】:
我想改变这个 slideDown 效果:
$(document).ready(function () {
$('.slide').not("#n1").hide();
$('.slide').click(function () {
var $this = $(this);
var $next = $this.next();
if (!$next.length) {
$next = $this.siblings(".slide").first();
}
$this.css("z-index","-1"); //make sure $next can slide OVER $this
$next.slideDown(2000, function () {
$this.hide().css("z-index","0");
});
});
});
到这个动画效果:
$(document).ready(function () {
$('.slide').not("#n1").hide();
$('.slide').click(function () {
var $this = $(this);
var $next = $this.next();
if (!$next.length) {
$next = $this.siblings(".slide").first();
}
$this.css("z-index","-1"); //make sure $next can slide OVER $this
$next.animate({marginTop: "400px"}, 2000, function () {
$this.hide().css("z-index","0");
});
});
});
目标是从边缘上方向下滑动“下一个”div,以覆盖可见的 div。
.slide {height:500px;width:100%;background-color:#f2f2f2;border-bottom:5px solid #f2f2f2;position:absolute;}}
<div id="n1" class="slide" style="display:inline">div one</div>
<div id="n2" class="slide" style="display:block;margin-top:-400px">div two</div>
动画功能根本不起作用。任何人都可以帮助解决它吗?我是否正确使用动画: $next.animate({marginTop: "400px"}, 2000, function () {...
【问题讨论】:
-
好的,你的问题是什么?
-
动画根本不起作用。谁能推荐一个解决方案?我会编辑帖子。
标签: jquery jquery-animate