Bootstrap 元素居中设置

一、Bootstrap水平居中

1、 文本:class ="text-center"

2、 图片居中:class = "center-block"

3、其他元素:

 bootstrap3水平居中:利用bootstrap列偏移  class = "col-md-offset-4 col-lg-offset-4col-xl-offset-4"
 bootstrap4水平居中:class = "m-auto"
 

二、Bootstrap垂直居中

bootstrap3 如何让div内部垂直居中:

Bootstrap的栅格系统使用的是float:left的浮动方式,vertical-align属性不起作用,故把内部div的float属性清除,添加display属性,如下:

.middle {
float: none;
display: inline-block;
vertical-align: middle;
}

Bootstrap3登录框自适应水平居中+垂直居中

原文地址:https://www.cnblogs.com/nxmxl/p/11752374.html