我试了一堆东西来暂停jQuery,所以它等待CSS动画,但它总是立即跳转到。隐藏()。请帮忙!我想用CSS滑出一个元素,然后用jQuery隐藏它,但隐藏似乎忽略了动画
这里是我当前的代码:
$('#button').on("click", function() {
$("#main-content").toggleClass("hide-main-content").hide();
$("#csp-content").removeClass("hide-csp-content");
});
CSS:(注意:我使用的是一个超级exagerated 4.5S,因为我想确认它.hide之前完成()踢)。
.hide-main-content, .hide-csp-content {
right: -100vw !Important;
-webkit-transition: all 4.5s ease-in-out;
-moz-transition: all 4.5s ease-in-out;
-ms-transition: all 4.5s ease-in-out;
-o-transition: all 4.5s ease-in-out;
transition: all 4.5s ease-in-out;
}
#main-content, #csp-content {
background: #FFFFFF;
position: relative;
z-index: 10;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
top: 0;
right: -40vw;
width: 60vw;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
HTML:
<section id="main-content" class="hide-main-content">
<p>MAIN</p>
</section>
<section id="csp-content" class="hide-csp-content">
<p>CSP</p>
</section>
您的javascript切换类称为滑盖主要内容和幻灯片-CSP-内容,但HTML和CSS参考捉迷藏的主要内容和隐藏-CSP-内容。是否打算在2个不同的CSS类之间切换来隐藏/显示?如果是这样,幻灯片的CSS在哪里? - 内容类? – clav
clav,在试图简化我的页面为我的帖子我犯了一些错误,抱歉我现在更新了CSS。 – Player
听起来像jQuery [animate](http://api.jquery.com/animate/)的工作,您将在其中传递给_complete_函数的'removeClass'执行。 –