Flexbox实现垂直水平居中

<div class="box">
        <div style="width: 100px;height:150px;">
            解析:本题主解析:本题主解析:本题主
        </div>
    </div>
    <style type="text/css">
        .box {   
            display: flex;  
            align-items: center;  //垂直

    -webkit-align-items: center;//兼容浏览器写法
            justify-content: center; //水平

    -webkit-justify-content: center;//兼容浏览器写法
            height: 500px;
            width: 300px;
        }  
    </style>

 

posted @ 2016-07-15 17:18  xiaoxiao333  阅读(114)  评论(0编辑  收藏  举报