欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

css实现多行文字垂直居中

程序员文章站 2022-07-15 14:49:48
...

flex方法

<div class="father">
        <div class="children">
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
            <span>多行文字垂直居中</span>
        </div>
    </div>
html,
    body {
        margin: 0;
        padding: 0;
        background-color: skyblue;

    }

    .father {
        width: 300px;
        height: 300px;
        background-color: pink;
        display: flex;
        justify-content: center;
        align-items: center;
    }
.children{
    background-color:blue;
}

效果

css实现多行文字垂直居中