CSS之 background-size

Posted eddyz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSS之 background-size相关的知识,希望对你有一定的参考价值。

https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

 

The background-size CSS property sets the size of the element‘s background image. The image can be left to its natural size, stretched, or constrained to fit the available space.

 

comma.

Values

contain
Scales the image as large as possible without cropping or stretching the image.
cover
Scales the image as large as possible without stretching the image. If the proportions of the image differ from the element, it is cropped either vertically or horizontally so that no empty space remains.
auto
Scales the background image in the corresponding direction such that its intrinsic proportions are maintained.
<length>
Stretches the image in the corresponding dimension to the specified length. Negative values are not allowed.
<percentage>
Stretches the image in the corresponding dimension to the specified percentage of the background positioning area. The background positioning area is determined by the value of background-origin (by default, the padding box). However, if the background‘s background-attachment value is fixed, the positioning area is instead the entire viewport. Negative values are not allowed.

以上是关于CSS之 background-size的主要内容,如果未能解决你的问题,请参考以下文章