首页 > 其他 > 详细

竖向图片两边留白,横向图片上下留白

时间:2018-04-08 15:17:01      阅读:245      评论:0      收藏:0      [点我收藏+]

给父盒子加相对定位

.rater-main .rater-img2{
width: 266px;
height: 196px;
overflow: hidden;
background-color: #fff;
position: relative;
}

 

给子元素绝对定位

.rater-main > li img{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
max-width: 100%;
max-height: 100%;
}

竖向图片两边留白,横向图片上下留白

原文:https://www.cnblogs.com/longsf/p/8744811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!