原文链接:http://www.ruanyifeng.com/blog/2010/03/css_cookbook.html

文字的水平居中

1 text-align:center

容器的水平居中

div #container{
width:760px;
margin:0 auto;
}

文字的垂直居中

<div id="container">123456</div>
div #container{
height:35px;
line-height:35px;
}

如果有n行文字,那么将行高设为容器高度的n分之一即可。

 

posted on 2016-06-02 14:26  jtZby  阅读(71)  评论(0)    收藏  举报