I’m trying to center 1 #div box with two small #divs inside of it, to be in the exact middle of the screen/page – ideally across all resolutions and IE 6 +, whats the best approach?
margin:0 auto;
seems to do the trick horizontally, but what about vertically?
If you know the size of the element you want to center, you can set the following CSS for it to center horizontally and vertically:
Note that the parent of the element needs to have
positionset to something other thanstatic:Here is a jsfiddle: http://jsfiddle.net/jasper/rcN3P/
P.S. I checked and this works in I.E. 6.