考虑遵循 HTML。我有.image
并.details
包裹在.wrap
. 在外部.wrap
,我有另一个 div .extra
,我最初想隐藏它,但仅将鼠标悬停在图像 div上,我想将它向下滑动,以便它占据整个区域。.wrap
我正在尝试以下代码,但不起作用:
HTML:
<div class="box">
<div class="wrap">
<div class="image"><img src="http://farm9.staticflickr.com/8075/8310628243_d48e64dc66_m.jpg" /></div>
<div class="details">xxx</div>
</div>
<div class="extra">hidden, show on hover over .image</div>
</div>
CSS:
.box{
border: 1px solid red;
width: 240px;
}
.image{
border: 1px solid green;
position: relative;
}
.extra{
position: absolute;
top: -100%;
left: 0;
background: green;
}
.box .image:hover .extra{
top: 0;
}
演示:http: //jsfiddle.net/pv9jd/