object-fit property in CSS
The object-fit CSS property sets how the content which includes images, videos and other embedded media formats should be resized to fit its container.
In the 👇 image, the object-fit property is applied to the lower row.
Let's get the ball rolling.
object-fit has one of these five values:
1. fill 2. contain 3. cover 4. none 5. scale-down
In order to understand the above values one by one, we'll use the below code throughout the article:
<!DOCTYPE html <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> img{ height: 120px; width: 400px; background-color: skyblue; } </style> </head> <body> <img src="cycling is meditation.jpg" alt=""> </body> </html>>
[Click to continue reading...]