好得很程序员自学网

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

css各种姿势的水平居中_html/css_WEB-ITnose

首先是最常用的,利用margin属性的auto来进行水平居中

margin: 0 auto;

其中0是指上下的margin,auto是左右的margin,margin这个属性的简写是按顺时针走的,也就是上、右、下、左。当参数为两个的时候第一个代表上下,第二个代表左右。

注意容器一定要有宽度才能使用这种方法。

                      #container{            width: 960px ;            height: 500px ;            background-color: red ;            margin: 0 auto;        }           

查看更多关于css各种姿势的水平居中_html/css_WEB-ITnose的详细内容...

  阅读:26次