首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >变暗的CSS背景图像?

变暗的CSS背景图像?
EN

Stack Overflow用户
提问于 2014-10-29 09:44:30
回答 1查看 271.1K关注 0票数 153

这应该是一个相当简单的问题。在我的网站上,我这样做:

代码语言:javascript
复制
#landing-wrapper {
    display:table;
    width:100%;
    background:url('landingpagepic.jpg');
    background-position:center top;
    height:350px;
}

我想要做的是使背景图像变暗。因为我在这个DIV中有UI元素,所以我不认为我真的可以在它上面放置另一个div来使它变暗。有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-29 09:52:32

您可以将CSS3 Linear Gradient属性与背景图像一起使用,如下所示:

代码语言:javascript
复制
#landing-wrapper {
    display:table;
    width:100%;
    background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url('landingpagepic.jpg');
    background-position:center top;
    height:350px;
}

下面是一个演示:

代码语言:javascript
复制
#landing-wrapper {
  display: table;
  width: 100%;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('http://placehold.it/350x150');
  background-position: center top;
  height: 350px;
  color: white;
}
代码语言:javascript
复制
<div id="landing-wrapper">Lorem ipsum dolor ismet.</div>

票数 405
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26621513

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档