Use of object-fit

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/hua_ban_yu/article/details/86676920

object-fit  Attribute specifies alternate elements of how the content should be adapted to the height and width of the frame to determine its use, commonly used in pictures, videos filled with problems.

object-fit the css properties:

  • object-fit: fill;
  • object-fit: contain;
  • object-fit: cover;
  • object-fit: none;
  • object-fit: scale-down;

 

contain

Replaced content will be scaled to maintain its aspect ratio when the contents of the frame padding element. It retains its aspect ratio of the whole object at the same time filling the box, so that if the aspect ratio does not match the aspect ratio of the frame, the object will be added " black edge ."

cover

Content is replaced frame holding the entire contents of which aspect ratio filling element simultaneously. If the object does not match the aspect ratio of the contents of the box, the object will be tailored to accommodate the contents of the box.

fill

SUMMARY replaced just filling contents block element. The entire object will completely fill this box. If the object does not match the aspect ratio of the contents of the box, then the object will be stretched to accommodate the contents of the box.

none

Replaced content maintains its original size.

scale-down

The size of the content  none or  contain in one and the same, depending on who get two between them will be smaller the size of the object.

 

Guess you like

Origin blog.csdn.net/hua_ban_yu/article/details/86676920