Home  >  Article  >  Web Front-end  >  CSS object-fit property value

CSS object-fit property value

WBOY
WBOYforward
2023-09-02 10:17:021232browse

CSS object-fit 属性值

#The object-fit property in CSS is used to resize an image or video to fit its container. It has the following values ​​

  • ## Contains: Scale content to fit
  • Cover: Crop to fit
  • Fill: Fill the content box.
Example

h2>You can try running the following code to implement the object-fit property with a cover value.

Live Demonstration

<!DOCTYPE html>
<html>
   <head>
      <style>
         .myimg {
            width:250px;
            height:350px;
            object-fit:fill;
         }
      </style>
   </head>
   <body>
      <h2>SWIFT</h2>
      <img class = "myimg"
         src = "https://www.tutorialspoint.com/assets/videos/courses/67/images/course_67_image.png"
         alt = "Python Data Science" width = "300" height = "200">
   </body>
</html>
p>

The above is the detailed content of CSS object-fit property value. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete