【发布时间】:2017-03-22 11:53:44
【问题描述】:
我只是在学习 Bootstrap,并试图找出一种用不透明背景图像显示内容的好方法。我目前正在使用“井”,但不必这样做。我可以得到井“内部”和不透明的图像,但我不能得到它“在”其他内容的“后面”。以下是 html 的一个小示例:
.background1{
background-size:cover;
opacity: .25;
max-width: 1130px;
}
<div class="well">
<div class="row">
<img class="img-rounded background1" src="/Images/housing-4-1213183.jpg" alt="housing" />
<h2>Section Title Here</h2>
<p>This is just a place holder for text content that would be showed on top of the desired image.</p>
</div>
</div>
如果有更好的类用于内容,请告诉我。
【问题讨论】:
-
您是想让文本位于半透明图像的顶部还是下方?你的问题不清楚。提醒:不透明的意思是“看不透”,半透明的意思是半透明的,透明的,显然是完全看透的。
-
但是,由于您尝试使用 css opacity 来调整图像的半透明度,因此解决方案是使用绝对定位和 z-indexing,因此将其从渲染流程中取出,允许您的“内容”要呈现在顶部(或下方,取决于 z-indexing 的完成方式)
-
mix3d 我希望图像在背景中“褪色”,并且“顶部”的文字不褪色。是不是更清楚了?
标签: javascript jquery html css twitter-bootstrap-3