<a class="position-relative heightAuto" href="javascrpt:;">
<img class="objectfit-scale" src="./images/302143215.jpg" alt="">
</a>
<style>
.position-relative{
position: relative;
width:500px;
height:500px; //可自定义
}
.objectfit-scale{
height: 100%;
width: auto;
left:50%;
position: absolute;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
-moz-transform: translateX(-50%);
object-fit: scale-down;
}
</style>
css图片根据父元素大小改变大小
猜你喜欢
转载自blog.csdn.net/qq_35376043/article/details/104614418
今日推荐
周排行