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>

  效果图如下:

posted @ 2018-07-23 14:58  贺小鸣  阅读(14937)  评论(0编辑  收藏  举报
为尊重他人劳动成果,转载/摘抄请标明来源!