<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title></title> </head> <style type="text/css"> *{padding: 0;margin: 0;} .box{width: 400px;height: 400px;border: solid 5px red;} .txt,.bug{display: inline-block;vertical-align: middle;*display:inline;zoom:1;} .txt{} .bug{height: 100%;width: 1px;} </style> <body> <div class="box"> <p class="txt">你妹啊妹啊<br>你妹啊妹啊</p> <p class="bug"></p> </div> </body> </html>
利用vertical-align居中的方法让文字相对于后面p标签一起居中
更多可参考大漠空间http://www.w3cplus.com/css/vertically-center-content-with-css