我肯定不会用 javascript 或 jQuery 来做,因为只有 CSS3 才有可能
这里是一个例子或查看小提琴http://jsfiddle.net/mpaas/:
#naviWrapper {
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
position:absolute;
top:-200px;
height:200px;
left:0px;
right:0px;
background:#ccc;
}
#naviWrapper:hover {
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
top:0px;
}
#naviButton {
position:absolute;
bottom:-60px;
left:50%;
margin-left:-50px;
width:100px;
height:60px;
background:#000;
color:#fff;
text-align:center;
}
<div id="naviWrapper">
<div id="naviButton">Hover!</div>
</div>
这是可行的,因为按钮元素是包装器的子元素,因此在悬停 naviButton 时,它将调用包装器元素上的悬停,它通过在 css 样式顶部给出的查询进行动画处理。