<div id='evalPage '>
<div class='imgbox'>
<img class='image__inner' src='http://https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg' />
</div>
</div>
#evalPage .imgbox{
width: 20%;
height:0; //容器内有内容,所以要将height设为0
padding-bottom: 20%; //这里和宽值一样
overflow: hidden;
position: relative;
}
#evalPage .imgbox .image__inner{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
}
css实现图片按宽等比例缩放不变形
最新推荐文章于 2024-05-13 10:29:58 发布