CSS object-fit property value

WBOY
Release: 2023-09-02 10:17:02
forward
1234 people have browsed it

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>
Copy after login
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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template