title: Vertical Centering, Unknown Height, Other Content on Page
body: <p>Alright, so this is basically the usual "how to vertically center with CSS" question, but with some catches.</p>
  
  <ol>
  <li><p>No Javascript. HTML and CSS only. CSS3 is fine as long as it's reasonably well supported by today's browsers.</p></li>
  <li><p>The element's content, and therefore height, is not known. It may be anywhere from a few dozen to a few hundred pixels. In the future I might even have a script adding and removing elements inside, so it may change height as the user is interacting with it.</p></li>
  <li><p>There is other content on the page - a navigation bar at the left and a menu at the top. These need to be accessible.</p></li>
  </ol>
  
  <p>The approach I've used is the three-container-div method using display: table-cell, as documented at: <a href="http://www.jakpsatweb.cz/css/css-vertical-center-solution.html" rel="nofollow">http://www.jakpsatweb.cz/css/css-vertical-center-solution.html</a>  this solves issues 1 and 2, but not 3. </p>
  
  <p><a href="http://imgh.us/vcenter.jpg" rel="nofollow">http://imgh.us/vcenter.jpg</a>  shows the design and the problem. The yellow box is the innermost container. The red and green dotted boxes around the entire page (which have become somewhat blurred together due to JPEG encoding) are the outermost and middle containers respectively. (The out-of-place footer is a separate issue...)</p>
  
  <p>The problem with this layout is the outer containers cover the entire page, and this makes it impossible to click on the navbar, because it's now "under" those containers. Z-index can move them to the bottom, but then it becomes impossible to click on anything inside the red box, because it's now "under" the page's main content box. (XHTML only allows a single element inside the &lt;body&gt;, so I've just wrapped it all in a &lt;div&gt;.) Even if the outer two containers have z-index: -100 and the inner container has z-index: 200, it still ends up under the main content box for some reason. (I did try various position attributes.)</p>
  
  <p>The only solution I've seen is a new CSS3 property, pointer-events, that would in theory allow me to make events pass through the transparent containers as I'd expect; however this seems to be quite new and not yet supported by most browsers outside of SVG, and I imagine I'd have the same trouble as with Z-index.</p>
  
  <p>I do want the element at the center of the page, not the center of the content area (i.e. ignoring navbars in the calculation of position), so placing the container inside the content area isn't an ideal solution. (I'm using this style on the login page as well, which has no navbars, and it'd look a bit strange if the "centered" elements were centered relative to a navbar that isn't always visible.)</p>
  
  <p>In summary what I need is to center, without using Javascript, an element of unknown height on a page with other content at its edges, without covering any of the content with an invisible layer (and thus making it unclickable).</p>