我有一个简单的程序,可以将图像从数据库中回显到页面。我想要一个子元素,只是一个简单的透明框,显示在图像的顶部。图片DIV覆盖儿童DIV
我知道子元素总是比父元素有更高的z-index,但图像总是覆盖我想要的顶部框。当页面正在加载时,我可以看到我想要的位置的框,但是当图像加载并且框消失时。
这里是一个的jsfiddle:http://jsfiddle.net/EBvCZ/
PHP
echo '<div id="wrapper">';
while ($data = mysql_fetch_array($query_run)) {
echo '<div id="picback"><div id="centerpic"><a href="image.php?photo_id='.$data['photo_id'].'" title="View Photo"><'.'img src="resizeimage.php?photo_id='.$data['photo_id'].'"></a>';
echo '<br style="clear:both;" />';
echo '<div id="titlepic">This is an image</div>';
echo '</div></div>';
}
echo '</div>
CSS
#wrapper {
overflow:auto;
width:1000px;
height:1000px;
margin: 20px auto;
}
#titlepic {
background-color:rgba(0, 0, 0, 0.5);
top:100px;
width:200px;
height:35px;
position:relative;
}
#centerpic {
position:relative;
margin:auto;
width: 200px;
height: 150px;
top:18.75px;
overflow:hidden;
}
#picback {
position:relative;
margin:10px 23px;
top:75px;
float:left;
width:250px;
height:187.5px;
overflow:hidden;
}
#picback:hover {
background-color:rgb(190,190,190);
-webkit-border-radius:0.4em;
-webkit-transition: background-color 0.5s;
}
一个jsFiddle会很好; P – 2013-03-03 01:35:11
我为你添加了一个jsFiddle。 – Pachonk 2013-03-03 02:48:02
@Pachonk谢谢! – user2127833 2013-03-03 05:20:24