在jquery中,我正在做一个小动画。在那里我采取了两个div。所以基本上逻辑就是这样,当鼠标悬停时,它会显示一个带有转换的隐藏div。第二格也是一样的概念。但我的问题是,当我在第一个div上悬停时,它显示了转换中的隐藏div。但是当我在另一个div上悬停时,第一个隐藏的是隐藏的,第二个隐藏的div显示在第二个div中。所以我想,当我将鼠标悬停在第二个div上时,第一个隐藏的div应该先隐藏,然后第二个隐藏的div将被显示。jQuery知道第一个过渡已经完成,然后使第二个
这里是我到目前为止的代码
<div id="wrapper">
<div class="courses-method-left-wrapper">
<div class="courses-method-wrap left">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem </p>
</div>
<div class="online-course-price-wrap">
<h3>Left content wrap</h3>
<h6>Left content text</h6>
</div>
</div>
<div class="courses-method-right-wrapper">
<div class="courses-method-wrap right">
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem </p>
</div>
<div class="offline-course-price-wrap">
<h3>Right content wrap</h3>
<h6>Right content text</h6>
</div>
</div>
</div>
我的CSS到目前为止
#wrapper {
width: 100%;
clear: both;
overflow: hidden;
background: #D7DFE6;
position: relative;
}
.courses-method-left-wrapper, .courses-method-right-wrapper {
width: 45%;
padding: 10px;
overflow: hidden;
float: left;
position: relative;
}
.courses-method-wrap.left {
float: left;
position: relative;
left: 0px;
}
.courses-method-wrap.right {
position: relative;
}
.online-course-price-wrap {
width: 230px;
background: #1C2C39;
position: absolute;
right: -230px;
height: 200px;
}
.offline-course-price-wrap {
left: -200px;
z-index: 0;
width: 200px;
position: absolute;
height: 100%;
top: 0px;
background: #ccc;
height: 200px;
}
.hovered .online-course-price-wrap { right: 0px; }
.hovered .offline-course-price-wrap { left: 0px; }
#wrapper * {
-webkit-transition: all 0.7s ease-out;
transition: all 0.7s ease-out;
-moz-transition: all 0.7s ease-out;
}
和js代码是这样的
jQuery('body').on('hover','.courses-method-left-wrapper, .courses-method-right-wrapper', function(){
jQuery(this).toggleClass('hovered');
});
这里是小提琴link
因此,有人可以告诉我如何在一个转换完成之后完成另一个转换,或者我应该如何检查第一个动画是否已经完成,以便第二个动画可以启动?任何帮助和建议都将非常可观。谢谢
相关:[CSS3过渡事件](http://stackoverflow.com/questions/2794148/css3-过渡事件) – 2015-02-24 12:48:47
我个人认为,隐藏第一个div并行显示第二个div看起来更好,然后等待第一个div完全隐藏,然后显示第二个div。 – Stefan 2015-02-24 12:55:50