http://blog.csdn.net/yaoyyl/article/details/50548589
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>让DIV标签中的P标签水平和垂直都居中</title>
- <style type="text/css">
- div {
- width:400px;
- height:300px;
- border:1px solid #666;
- overflow:hidden;
- position:relative;
- display:table-cell;
- text-align:center;
- vertical-align:middle;
- }
- p {
- border:1px solid #333;
- width:100%;
- }
- * { margin:0; padding:0;}
- </style>
- </head>
- <body>
-
- <div>
- <p>我是多行文本,我要水平和垂直都居中。</p>
- <p>且要完全兼容ff和ie。我是多行文本,我要水平和垂直都居中。且要完全兼容ff和ie。</p>
- </div>
-
- </body>
- </html>
让DIV标签中的P标签水平和垂直都居中
原文:http://www.cnblogs.com/zaifeng0108/p/7226422.html