【发布时间】:2013-01-01 20:13:37
【问题描述】:
在下面的 HTML 中,.layer 的初始位置设置为 top: -100%,我想在将鼠标悬停在 .image div 上时更改它。我正在尝试以下代码,但它似乎在悬停时没有做任何事情。
HTML:
<div class="box">
<div class="image">
<a href="#"><img src="http://farm9.staticflickr.com/8356/8332233161_18e3a75de0_m.jpg" ></a>
</div>
<div class="layer">Hide it first, show on hover over image</div>
<div class="other">other</div>
</div>
CSS:
.box{
border: 1px solid red;
width: 240px;
}
.box .image{
position: relative;
overflow: hidden;
}
.box .layer{
width: 240px;
height: 146px;
background: green;
position: absolute;
top: -100%;
}
.box .image:hover .layer{
top: 0
}
JSFiddle: http://jsfiddle.net/pY9jx/
【问题讨论】: