Object Fit Css
Used by itself object fit lets us crop an inline image by giving us fine grained control over how it squishes and stretches inside its box.
Object fit css. The css3 css image values and replaced content module working draft define a property called object fit which aims to solve exactly these sorts of problems. All values of the css object fit property. Css object fit 属性 实例 对图片进行剪切 保留原始比例 mycode3 type css img a width. They give developers control over the content inside an img or a video similar to the way that we can manipulate the content of a background with background position and background size.
It s intended for images videos and other embeddable media formats in conjunction with the object position property. The object fit css property is used to specify how an or should be resized to fit its container and the object position css property is used together with object fit to specify how an or should be positioned with x y coordinates inside its own content box. The object fit css property sets how the content of a replaced element such as an img or video should be resized to fit its container. The replaced content is sized to fill the element s content box.
Object fit and object position are my two favourite css properties lately. If necessary the object will be stretched or squished to fit. This property defines how an element such as an img responds to the width and height of its. The object fit property can have the following values.
Fill this is default. The object fit property defines how an element responds to the height and width of its content box.