Home
CSS
CSS object-fit
Tryit: Using object-fit: cover
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h2>Using object-fit</h2> <p>Here we use "object-fit: cover;", so when we resize the browser window, the aspect ratio of the images is preserved:</p> <div style="width:100%;height:400px;"> <img src="rock600x400.jpg" alt="Norway" style="float:left;width:50%;height:100%;object-fit:cover;"> <img src="paris.jpg" alt="Paris" style="float:left;width:50%;height:100%;object-fit:cover;"> </div> </body> </html>