Vertically Center In Browser

Out of context: Reply #19

  • Started
  • Last post
  • 19 Responses
  • rafalski0

    css creators were dumb design ignorants and the idea of vertical centering the whole site never came to their small minds. The only html element which content can be vertically centered is table cell, TD (TH prolly too).

    You can assign table cell behaviour to elements though:

    html {height:100%; display:table}
    body {display:table-cell; vertical-align:middle;}

    Note that this stupid code doesn't work in IE, as it doesn't understand display:table nor display:table-cell, hahahaha..

    Other ways to center require you to know the element height, which is not always an acceptable solution

View thread