1、单行居中
这个也简单直接line-height为容器的高度就行了。
2、多行居中
和上面的单行居中差不多,只是line-height的值发生了变化,用容器高度除以行数,得到的结果就是line-height的值。
3、DIV垂直居中。这个也分为两种情况
3.1、DIV知道高度的情况,这里就需要用到定位,下面是具体代码。
Document *{ margin: 0; padding: 0; } body{ width: 100%; height: 100%; } div{ width: 100%; height: 400px; position: absolute; top: 50%; left: 0; margin-top: -200px; background: red; } .box{ width: 100%; height: 380px; margin-top: -180px; background: black; }
查看更多关于关于的垂直居中的问题_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did110667