首页 > 其他 > 详细

垂直居中的方法总结

时间:2017-05-05 12:18:40      阅读:256      评论:0      收藏:0      [点我收藏+]

方法一:绝对定位

.photo{overflow: hidden;position: relative;width: 100%;height: 100%;}
img{width: 100%;position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);}

方法二:绝对定位

.photo{overflow: hidden;position: relative;width: 100%;height: 100%;}
img{width: 100%;position: absolute;top: 0;bottom: 0;left:0;right:0;margin:auto;}

方法三:table-cell

.photo{width: 100%;height: 100%;display:table-cell;text-align:center;vertical-align: middle;}
img{width: 100%;position: absolute;top: 0;bottom: 0;left:0;right:0;margin:auto;}

垂直居中的方法总结

原文:http://www.cnblogs.com/weihongqiang/p/6812338.html

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