Center a H1 tag inside a DIV

后端 未结 7 841
遥遥无期
遥遥无期 2020-12-15 15:39

I have the following DIV inside a body tag:

Yes

And these are their CSS classes

7条回答
  •  自闭症患者
    2020-12-15 16:07

    You can use display: table-cell in order to render the div as a table cell and then use vertical-align like you would do in a normal table cell.

    #AlertDiv {
        display: table-cell;
        vertical-align: middle;
        text-align: center;
    }
    

    You can try it here: http://jsfiddle.net/KaXY5/424/

提交回复
热议问题