View Full Version : Dynamic Height Div

09-18-2007, 02:24 AM
Hey all,

Made a not-so-common layout for one of my sites. It's about 300px high and 100% wide. SInce its a Horizontal page, I want it to be centered in the browser.

I was thinking of putting 3 divs, being that the middle one has a static height and the other two have the difference split in two in order to keep the middle div centered vertically.

any ideas on how?

09-18-2007, 02:40 AM
This should work for you. You must use this Doctype or it won't work in IE 7.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body style="margin:0;padding:0;">
<div style="height: 300px; width: 600px; margin: 0 auto; background-color: gainsboro;">Test</div>

09-18-2007, 12:47 PM
Vertically centred, 100% width? this should work for you...

Attached html file. Drop the txt extension.

09-19-2007, 02:02 AM
centered vertically.

Sorry, I wasn't paying close enough attention I guess.