Vertically center a div with variable height within a div that is 100% of the viewport

前端 未结 1 1879
不思量自难忘°
不思量自难忘° 2021-01-18 09:26

I know it looks like a question that has been asked many times, but I just couldn\'t find the solution to that very specific situation.

Here\'s the basic wireframe o

相关标签:
1条回答
  • 2021-01-18 09:57

    Set a grandparent element to be display:table; height:100% and the parent element to be display:table-cell; vertical-align:middle.

    See "Method 1" here for an example.

    Also, note that your markup should not use class="centered"; use a semantic class name instead.

    0 讨论(0)
提交回复
热议问题