版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chenbetter1996/article/details/83031456
绝对居中
.xx_div {
position: absolute;
/* left, right, bottom, top要和position一起使用,margin-*不用 */
top: 0;
left: 0;
right: 0;
bottom: 0;
}
这样div框就会绝对显示在网页中间
浮动居中
float只有left和right,没有center。 可以如下设置居中
.xx_div {
margin-left: auto;
margin-right: auto;
}