Align vertically using CSS 3

后端 未结 8 1203
忘了有多久
忘了有多久 2020-11-30 19:21

With CSS 3, are there any way to vertically align an block element? Do you have an example? Thank you.

8条回答
  •  长情又很酷
    2020-11-30 19:53

    Note: This example uses the draft version of the Flexible Box Layout Module. It has been superseded by the incompatible modern specification.

    Center the child elements of a div box by using the box-align and box-pack properties together.

    Example:

    div
    {
    width:350px;
    height:100px;
    border:1px solid black;
    
    /* Internet Explorer 10 */
    display:-ms-flexbox;
    -ms-flex-pack:center;
    -ms-flex-align:center;
    
    /* Firefox */
    display:-moz-box;
    -moz-box-pack:center;
    -moz-box-align:center;
    
    /* Safari, Opera, and Chrome */
    display:-webkit-box;
    -webkit-box-pack:center;
    -webkit-box-align:center;
    
    /* W3C */
    display:box;
    box-pack:center;
    box-align:center;
    } 
    

提交回复
热议问题