超过显示尺寸会裁剪
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style type="text/css">
img{
margin:10px;
vertical-align: top;
}
.img1{
width:200px;
height:200px;
object-fit:cover;
/*object-fit:none;*/
/*object-fit:scale-down;*/
}
</style>
</head>
<body>
接口返回图片格式不一致时处理object-fit:cover;
<div class="box">
<pre><h1>修改平铺效果 默认显示效果</h1></pre>
<h4>横屏图片展示</h4>
<p>
<img class="img1" src="heng.png" alt="" srcset="heng.png"/><img src="heng.png" alt="" />
</p>
<h4>竖屏图片展示</h4>
<p>
<img class="img1" src="shushu.png" alt="" srcset="shushu.png"/><img src="shushu.png" alt="" />
</p>
<h4>小图片展示</h4>
<img class="img1" src="sm.png" alt="" srcset="sm.png"/><img src="sm.png" alt="" />
</div>
</body>
</html>