css3 background

2015-04-24 16:38:40 +08:00
 whatisnew
body {
  background-image: 
    linear-gradient(to bottom, rgba(0,0,0, 0.1), rgba(0,0,0, 1)),   
    url(img/bg.jpg);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
}

这样的 css3 可以把 background-image 分开写吗?
比如,覆盖 body 规则,同时又保留 linear-gradient

body.cover {
  background-image: url(img/other.jpg);
  /* 同时保留 linear-gradient(to bottom, rgba(0,0,0, 0.1), rgba(0,0,0, 1)) */
}
2946 次点击
所在节点    CSS
3 条回复
abelyao
2015-04-24 16:55:55 +08:00
body.cover 的 background-image 属性会覆盖 body 的,所以 linear-gradient 部分应该也会没了吧
zythum
2015-04-24 18:33:02 +08:00
对不起。不行。
iyangyuan
2015-04-24 19:58:19 +08:00
over的时候也加上渐变不就行了?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/186055

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX