我有以下html代码,以使“底部” div浮在图像顶部。我在一排桌子上有3张图片。
<td>
<img src="adele.jpg" alt="Adele">
<div id="bottom">
<h4 class="topText">ALBUM</h4>
<h3 class ="topText">ADELE 21 COVER </br> ADELE</h3>
</div>
</td>
这是我的CSS:
#bottom{
position: absolute;
display: inline-block;
bottom: 0px;
left:0px;
}
#positionAnchor {
position: relative;
}
就像您在图像中看到的那样,最上面的图片文本也没有正确地漂浮在图像的顶部。
您需要使用position:relative来设置窗口,其中position:absolute将用于顶部,左侧,底部和右侧。
<td >
<div id="positionAnchor">
<img src="adele.jpg" alt="Adele">
<div id="bottom">
<h4 class="topText">ALBUM</h4>
<h3 class ="topText">ADELE 21 COVER </br> ADELE</h3>
</div>
</div>
</td>
#bottom{
position: absolute;
display: inline-block;
bottom: 0px;
left: 0px;
}
#positionAnchor {
position: relative;
display: inline-block;
text-align:center;
}
否则,它将基于浏览器屏幕而不是父标记定位。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句