您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

使CSS背景图片变暗?

使CSS背景图片变暗?

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

#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;
}

这是一个演示:

#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;

}


<div id="landing-wrapper">Lorem ipsum dolor ismet.</div>
CSS 2022/1/1 18:24:59 有384人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶