【发布时间】:2018-03-17 12:37:33
【问题描述】:
图像覆盖了DIV的背景颜色,但显示了文字。
我的代码是
<div id="testing">
<img src="https://images.unsplash.com/uploads/1413142095961484763cf/d141726c?dpr=1&auto=compress,format&fit=crop&w=1350&h=&q=80&cs=tinysrgb&crop=">
<div id="sample">
Text
</div>
</div>
CSS 是
#testing {
width: 200px;
height:150px;
}
img {
width:200px;
height:150px;
}
#sample {
margin-top:-15px;
background: black;
color: white;
text-align:center;
}
结果是这样的
您可以在以下位置找到代码
https://jsfiddle.net/cz605rc5/
它可以解决div的背景css。
但我更喜欢使用img,并且想在图片底部覆盖黑色背景标签。
【问题讨论】:
-
我无法理解你的问题。您能否让我们更好地了解您的问题以及您希望最终结果是什么?
-
@andrewgu ,你可以在问题的最后看到,“想要覆盖图像底部的黑色背景标签”
标签: css