Div "Height" Property Tip

Sometimes on a web page you have a div container with 2 or more divs within. In many cases, you'll want the background from one of the divs to fill the container div. Unfortunately, the div style property height does not support a percentage value as of XHTML 1.1. Instead, you can "fool" the div by repeating the background on the container control like this:

<div id="container" style="background-image: url('containerbkg.gif'); background-repeat: repeat-y;">
    <div id="menu" style="float: left; width: 100px;">
        Item 1<br/>
        Item 2
    </div>
    <div id="body" style="margin-left: 100px; width: 300pt;">
        Body goes here<br/><br/>
        Body continues here<br/><br/>
        Body ends here.
    </div>
</div>
Published Thursday, June 01, 2006 4:12 PM by Jason N. Gaylord

Comments

# re: Div "Height" Property Tip

Thursday, May 01, 2008 3:15 AM by Tobbs

Div height may be set to a % in some cases

www.webmasterworld.com/forum83/200.htm

# re: Div "Height" Property Tip

Tuesday, June 10, 2008 1:34 AM by netra

i want to autofit div tag height in mozilla browser, i have great problem, can you help me????????

Netra.

Leave a Comment

(required) 
(required) 
(optional)
(required)