objectFit 属性用于指定如何调整 <img> 或 <video> 的大小以适合其容器。
该属性告诉内容以多种方式填充容器;例如"preserve that aspect ratio" 或"stretch up and take up as much space as possible"
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
objectFit | 31.0 | 16.0 | 36.0 | 7.1 | 19.0 |
返回 objectFit 属性:
object.style.objectFit
设置 objectFit 属性:
object.style.objectFit = "fill|contain|cover|scale-down|none|initial|inherit"
Value | Description |
---|---|
fill | This is default. The replaced content is sized to fill the element's content box. If necessary, the object will be stretched or squished to fit |
contain | The replaced content is scaled to maintain its aspect ratio while fitting within the element's content box |
cover | The replaced content is sized to maintain its aspect ratio while filling the element's entire content box. The object will be clipped to fit |
none | The replaced content is not resized |
scale-down | The content is sized as if none or contain were specified (would result in a smaller concrete object size) |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
默认值: | 充满 |
---|---|
返回值: | 一个字符串,表示元素的对象适合度 |
CSS版本 | CSS3 |
CSS教程:CSS 对象适配
CSS 参考:对象适合性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!