gpt4 book ai didi

html - 使 CSS 背景图像变暗

转载 作者:可可西里 更新时间:2023-11-01 13:47:26 24 4
gpt4 key购买 nike

我想使背景图片变暗。我发现我必须使用不透明度,所以我写了我的 css 代码:

body {
width: 960px;
margin: 0 auto;
font-family: Georgia, Times, serif;
background:
linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)),
url('../pics/parachute.jpg');}

一切正常!然而,当我添加一些标志来制作全屏背景图片时,我的效果消失了。

body {
width: 960px;
margin: 0 auto;
font-family: Georgia, Times, serif;
background:
linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)),
url('../pics/parachute.jpg');
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;}

它不起作用的原因是什么?

最佳答案

这就是您可以在不丢失任何应用效果的情况下使背景图像变暗的方法。

   

.bg{
background: url('http://res.cloudinary.com/wisdomabioye/image/upload/v1462961781/about_vbxvdi.jpg');
height: 500px;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.content{
background: rgba(0,0,0,0.4);
color: white;
height: inherit;
padding-left: 10px;
}
<div class='bg'>

<div class='content'>
<p>
Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some Some content Some content Some content Some content Some content Some

</p>
</div>
</div>

关于html - 使 CSS 背景图像变暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40239706/

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