backgroundSize 属性设置或返回背景图片的大小。
返回背景大小属性:
object.style.backgroundSize
设置背景大小属性:
object.style.backgroundSize = "auto|
length|cover|contain|intial|inherit"
Value | Description |
---|---|
auto | Default value. The background-image contains its width and height |
length | Sets the width and height of the background image. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto" |
percentage | Sets the width and height of the background image in percent of the parent element. The first value sets the width, the second value sets the height. If only one value is given, the second is set to "auto" |
cover | Scale the background image to be as large as possible so that the background area is completely covered by the background image. Some parts of the background image may not be in view within the background positioning area |
contain | Scale the image to the largest size such that both its width and its height can fit inside the content area |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
默认值: | 汽车 |
---|---|
返回值: | 一个字符串,表示元素的背景大小属性 |
CSS版本 | CSS3 |
backgroundSize
是 CSS3 (1999) 的一项功能。
所有浏览器都完全支持它:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!