p标签在div中水平垂直居中且文本左对齐
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> *{margin: 0;padding: 0} .box{width:800px;height:100px;background:#ccc;text-align: center} .box p {margin:0;padding:0;display: inline-block;vertical-align: middle;text-align: left} #liu_area{display: inline-block;height:100%;vertical-align: middle;} #p_span{display: block} </style> </head> <body> <div class="box"> <p> <span id="p_span">第一行</span> <span id="p_span">第二行</span> </p> <span id="liu_area"></span> </div> </body> </html>
效果图如下: