【发布时间】:2014-12-06 16:00:18
【问题描述】:
我试图拥有 2 个大小相同的 div,一个最初可见,而另一个(如下?)最初是隐藏的。
我希望当您将鼠标悬停在第一个 div 上时,另一个会动画并向上滑动以完全覆盖第一个。在您停止将鼠标悬停在该区域上之前,它应该保持在原位。
我可以让第二个 div 在悬停时向上移动,但它有许多不需要的效果 - 例如当第二个 div 就位时会出现跳跃/抖动行为 - 在这个小提琴中,较低的那个开始可见。
http://jsfiddle.net/cc28samh/1/
HTML
<div>
<div id="stay-in-place">
<h1>hello world</h1>
<p>ipsum dolorum caveat emptor veni vidi vici</p>
</div>
<div id="move-in-to-place">
<h2>I'm on top</h2>
</div>
</div>
风格
<style type="text/css"> #stay-in-place {
position:relative;
height : 200px;
width : 200px;
background: red;
-webkit-transition: height 1s, -webkit-transform 1s;
transition: height 1s, transform 1s;
}
#stay-in-place:hover {
height : 0px;
}
#move-in-to-place {
position:absolute;
height : 200px;
width : 200px;
background: blue;
}
</style>
【问题讨论】: