gpt4 book ai didi

html - 背景 : url and filter:brightness

转载 作者:太空宇宙 更新时间:2023-11-04 08:44:48 26 4
gpt4 key购买 nike

我想用 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>

最佳答案

其实我说亲子的时候是错的。您必须将容器放在同一层下:

#about_header {
background: url("http://www.thestatedhome.com/media/catalog/category/13514044-brown-natural-linen-texture-for-the-background-Stock-Photo.jpg") no-repeat center center fixed;
filter: brightness(20%);
height: 400px;
position: relative;
width: 100%;
background-size: cover;
}

.container {
display: table;
position: absolute;
top: 0px;
height: 400px;
width: 100%;
}

.text-vcenter {
display: table-cell;
text-align: center;
vertical-align: middle;
}

.container h1 {
color: white;
}
<section id="about_header"></section>
<div class="container">
<div class="text-vcenter">
<div class="row">
<div class="col-sm-12">
<div>
<h1>Contact us</h1>
</div>
</div>
</div>
</div>
</div>

关于html - 背景 : url and filter:brightness,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43859564/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com