好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css处理水平居中问题

1、水平居中设置-行内元素

通过父元素设置 1 text-align:center; ,让父元素的内容居中

2、水平居中设置-定宽块状元素

块状元素的宽度width为固定值,通过设置[左右margin]值为[auto]来实现居中的

例子:

 
 
 
 
 定宽块状元素水平居中 
 
div{
    width: 200px;/*固定的宽度*/
    margin: 20px auto;/*左右margin设置为auto*/
    border: 1px solid red;
}
 
 
 

我是定宽块状元素,我要水平居中显示。

查看更多关于css处理水平居中问题的详细内容...

  阅读:32次