How to include the background-cover value in the shorthand background property?

前端 未结 4 1786
遥遥无期
遥遥无期 2020-12-02 13:02

I am trying to set a background-image to stretch to the full extent of a

\'s width and height. The
will be of variable size,
4条回答
  •  盖世英雄少女心
    2020-12-02 13:25

    Good question this is from W3C http://www.w3.org/community/webed/wiki/CSS_shorthand_reference

    So if you want to include the background-size value in the shorthand syntax, you need to:

    • Explicitly include background-position values even if these are the same as the defaults Write background-position values before background-size values. Put a slash in between these two pairs of values.

    So you would want to do something like this

    background: url(http://www.stanford.edu/dept/CTL/cgi-bin/academicskillscoaching/wp-content/uploads/2013/03/test-anxiety.gif) top left / cover no-repeat;
    

    See fiddle here

    http://jsfiddle.net/8Up6V/

提交回复
热议问题