Vertically center text in a 100% height div?

后端 未结 13 690
傲寒
傲寒 2020-12-05 17:22

I am working with a div that is 100% of the parent divs height.

The div only contains a single line of text.

The div cannot have a fixed height.

So m

13条回答
  •  没有蜡笔的小新
    2020-12-05 17:37

    Try this one http://jsfiddle.net/Husamuddin/ByNa3/ it works fine with me,
    css

    .table {
        width:100%;
        height:100%;
        position:absolute;
        display:table;
    }
    .cell {
        display:table-cell;
        vertical-align:middle;
        width:100%;
        height:100%:
    }
    

    and the html

    Hello, I'm in the middle

提交回复
热议问题