【发布时间】:2017-05-09 10:23:33
【问题描述】:
我想用 filter:brightness 使 div 的背景图像变暗。它运作良好,但显然它会使整个 div 变暗,而不仅仅是图像。如何使用 CSS 仅使背景图像变暗?我想在上面写一些白色的文字。
这是我的代码:
#about_header {
background: url(../img/background/spa_02.jpg) no-repeat center center fixed;
filter: brightness(20%);
-webkit-filter: brightness(20%);
-moz-filter: brightness(20%);
-o-filter: brightness(20%);
-ms-filter: brightness(20%);
height:400px;
display: table;
position: relative;
width: 100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#about_header h1{
color: white;
}
<section id="about_header">
<div class="container text-vcenter">
<div class="row">
<div class="col-sm-12">
<div>
<h1>Contact us</h1>
</div>
</div>
</div>
</div>
</section>
【问题讨论】:
-
使用2个独立的
divs,一个作为具有背景和大小的父级,另一个仅包含内容并拉伸以填充父级。 -
我不明白,你能给我看看我的代码编辑吗?那么过滤器应该去哪里呢?