Can I apply multiple background colors with CSS3?

后端 未结 6 2061
死守一世寂寞
死守一世寂寞 2020-11-27 06:13

I know how to specify multiple background images using CSS3 and modify how they are displayed using different options.

Currently I have a

, w
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 07:10

    You can’t really — background colours apply to the entirely of element backgrounds. Keeps ’em simple.

    You could define a CSS gradient with sharp colour boundaries for the background instead, e.g.

    background: -webkit-linear-gradient(left, grey, grey 30%, white 30%, white);
    

    But only a few browsers support that at the moment. See http://jsfiddle.net/UES6U/2/

    (See also http://www.webkit.org/blog/1424/css3-gradients/ for an explanation CSS3 gradients, including the sharp colour boundary trick.)

提交回复
热议问题