CSS object-fit Property

CSSWeb DevelopmentFront End Technology

Use the object-fit property in CSS to resize image or video to fit its container.

Example

You can try to run the following code to learn how to work with the object-fit property −

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         .myimg {
            width:250px;
            height:350px;
            object-fit:cover;
         }
      </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>
raja
Published on 23-May-2018 08:00:31
Advertisements