V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Can I use?
http://caniuse.com/
Less
http://lesscss.org
Cool Libraries
Bootstrap from Twitter
Jetstrap
whatisnew
V2EX  ›  CSS

css3 background

  •  
  •   whatisnew · 2015-04-24 16:38:40 +08:00 · 2932 次点击
    这是一个创建于 3292 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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)) */
    }
    
    3 条回复    2015-04-24 19:58:19 +08:00
    abelyao
        1
    abelyao  
       2015-04-24 16:55:55 +08:00
    body.cover 的 background-image 属性会覆盖 body 的,所以 linear-gradient 部分应该也会没了吧
    zythum
        2
    zythum  
       2015-04-24 18:33:02 +08:00
    对不起。不行。
    iyangyuan
        3
    iyangyuan  
       2015-04-24 19:58:19 +08:00 via iPhone
    over的时候也加上渐变不就行了?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2701 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:31 · PVG 23:31 · LAX 08:31 · JFK 11:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.