让不规则的图片自适应居中

 

 

.xhcy_img {width:159px;height:94px;position: relative;overflow: hidden;display: flex;justify-content: center;align-items: center;}
.xhcy_img img {margin:0 auto;object-fit: cover;max-width:100%;max-height: 100%;width:auto;height: auto;}

 

 

<div class="xhcy_img">
    <img data-src="img.jpg" src="img.jpg" />
</div>

 

posted @   赵瑛  阅读(45)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战

版权所有 © 2022 沅来是澧

如果有程序开发、网站建设等需求的请联系我,QQ:47419233

点击右上角即可分享
微信分享提示