未知高度-纯css实现水平垂直居中

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <style>
        .p_wrap{ width:100%; height: 100%; position: fixed; left: 0;top: 0; z-index: 10000;}
        .p_wrap_mask{ width:100%; height: 100%; background:#000; filter:alpha(opacity=80); position: absolute; left: 0;top: 0; z-index:1;}
        .p_out { margin: 0 auto; height: 100%; width: 600px;  overflow: hidden; position: relative; z-index: 10; }
        .p_out {display: table; }
        .p_mid {position: absolute; top: 50%;}
        .p_mid{display: table-cell; vertical-align: middle; position: static; background: none;}
        .p_in {position: relative; top: -50%;width: 600px;margin: 0 auto;} 
        .p_in{padding: 10px;border-radius: 8px;background: #fff;}
        .p_in img{width: 100%;}
    </style>
    <!--图片弹窗-->
    <div class="p_wrap">
        <p class="p_wrap_mask"></p>
        <div class="p_out">
            <div class="row p_mid">
                <div class=" p_in" >
                    <div>
                        <img src="images/pic.jpg" alt="">
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>

  

posted @ 2017-06-23 10:11  ifIhaveWings  阅读(168)  评论(0编辑  收藏  举报