首页
CSS
CSS object-fit
Tryit: 使用 object-fit: cover
运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 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>