I’m having trouble vertical-aligning an element inside a div for the simple reason that you cannot give a div a height of 100%… I have a wrapper div right inside <body> & I want it to be same height as window-height, is this possible? it seems to me it should be possible with height:100%, then image could be vertical-align:middle… (img is about 600px high, it’s the only element on the page… I want it to be centered on the page, both horizontally and vertically… how do I do this…)
(img is about 600px high, it’s the only element on the page… I want it to be centered on the page, both horizontally and vertically… how do I do this…)
Hi maya,
If your image is the only element on the page I would be inclined to use Paul’s “Easy Vertical Centering” method.
The updated method uses a float and it is discussed about half way down the page as “The Fix”.
You could just set the static #hoz div to the same size as your image and it should work out fine. You could even set your image as a BG image on that div.
The #vertical float div sits on it’s own above the #hoz (content) div and controls the vertical centering, view the page source of the link below for details.