hymn

忽有故人心头过,回首山河已是秋。

  menu
132 文章
0 浏览
0 当前访客
ღゝ◡╹)ノ❤️

div 中子元素水平,垂直居中

<div id="box">test vertical align</div>
#box {
    width: 300px;
    height: 300px;
    background: #ddd;
    display: flex;
    align-items: center;/*垂直居中*/
    justify-content: center;/*水平居中*/
}

使用flex布局

display: flex;

align-items: center;


标题:div 中子元素水平,垂直居中
作者:hymn
地址:https://dxyhymn.com/articles/2020/07/06/1594028593547.html