2012-09-05 58 views
1

我想只顯示一個div時,鼠標上方徘徊他,我有這個網站:顯示懸停絕對定位的div不起作用

<div class="caption"> 
    <h2><a href="single-image.html">Sun Flower</a></h2> 
    <p class="meta-info-font">I took this photo at some bla bla bla.. and some other stuff.</p> 
</div> 

爲什麼不這項工作:

.caption { 
    position: absolute; 
    top: 40%; 
    left: 0; 
    right: 0; 
    background-color: rgba(20,19,19,0.94); 
    display: none; 
} 

.caption:hover { 
    display: block; 
} 

更新:如果我使用不透明度,它不會隱藏子元素 - h2p。我如何只用CSS來隱藏它們?

回答