V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
whatisnew
V2EX  ›  CSS

css3 background

  •  
  •   whatisnew · Apr 24, 2015 · 3474 views
    This topic created in 4020 days ago, the information mentioned may be changed or developed.
    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 replies    2015-04-24 19:58:19 +08:00
    abelyao
        1
    abelyao  
       Apr 24, 2015
    body.cover 的 background-image 属性会覆盖 body 的,所以 linear-gradient 部分应该也会没了吧
    zythum
        2
    zythum  
       Apr 24, 2015
    对不起。不行。
    iyangyuan
        3
    iyangyuan  
       Apr 24, 2015 via iPhone
    over的时候也加上渐变不就行了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   824 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 20:51 · PVG 04:51 · LAX 13:51 · JFK 16:51
    ♥ Do have faith in what you're doing.