css实现水平垂直居中方法

html:

<div class="box box1">
        <span>垂直居中</span>
</div>

法一:

.box1{
    display: table-cell;
    vertical-align: middle;
    text-align: center;        
}

法二:

.box2{
    display: flex;
    justify-content:center;
    align-items:Center;
}

法三:

.box6 span{
            position: absolute;
            top:50%;
            left:50%;
            width:100%;
            transform:translate(-50%,-50%);
            text-align: center;
        }

猜你喜欢

转载自blog.csdn.net/qq_36784628/article/details/82663754