首页 > 其他 > 详细

div居中问题

时间:2016-04-27 15:40:19      阅读:282      评论:0      收藏:0      [点我收藏+]

如何水平居中,方法有2:

1. 设置当前div的style为:margin: auto; 其实真正关键的是设置其margin-left和margin-right为auto,这样的目的是自动调整div以适应屏幕宽度,使其居中

2. 设置div的父级容器,例如body样式如下:

 body {
  display: flex;
  align-items: center;
  justify-content: center;
 }

如何垂直居中呢?以下是网上找到的方法,以后用到时再行验证:

http://fangwei.iteye.com/blog/442628

https://www.qianduan.net/css-to-achieve-the-vertical-center-of-the-five-kinds-of-methods/

 

div居中问题

原文:http://www.cnblogs.com/researcher/p/5439026.html

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