Center content in a absolute positioned div

后端 未结 4 961
慢半拍i
慢半拍i 2021-02-12 18:34

I have an absolutly positioned element with content inside. It can be a

or a few

tag. So I don\'t know the height of the content.

4条回答
  •  死守一世寂寞
    2021-02-12 19:28

    Change your #absolute div to also use:

    display:table;
    vertical-align:middle;
    text-align:center;
    

    http://jsfiddle.net/3KTUM/4/

提交回复
热议问题