该属性规定了背景图像的尺寸:
1 | div |
2 | { |
3 | background : url (img_flwr.gif); |
4 | background- size : 80px 60px ; |
5 | background-repeat : no-repeat ; |
6 | } |

定义和用法
background-size 属性规定背景图像的尺寸。
默认值: |
auto |
继承性: |
no |
版本: |
css3 |
JavaScript 语法: |
object.style.backgroundSize="60px 80px" |
语法:
1 | background- size : length|percentage|cover|contain; |
值 |
描述 |
length |
设置背景图像的高度和宽度。 第一个值设置宽度,第二个值设置高度。 如果只设置一个值,则第二个值会被设置为 "auto"。 |
percentage |
以父元素的百分比来设置背景图像的宽度和高度。 第一个值设置宽度,第二个值设置高度。 如果只设置一个值,则第二个值会被设置为 "auto"。 |
cover |
把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。 背景图像的某些部分也许无法显示在背景定位区域中。 |
contain |
把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域。 |