![CSS object-fit 属性值](https://img.php.cn/upload/article/000/887/227/169362102499369.jpg)
#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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <!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!