Results 1 to 4 of 4

Thread: div height attribute

  1. #1
    Join Date
    Nov 2005
    Posts
    132
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default div height attribute

    Hi,

    Is it possible to configure a div which is 10 pixels wide to always expand and contract to fit browser windows height?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Seems to require javascript enabled in IE (for the expression style rule) all others seem fine with pure style:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    #high {
    width:10px;
    height:100%;
    position:absolute;
    background-color:green;
    bottom:0;
    left:0;
    }
    * html #high {
    height:expression(document.all.tags('html')[0].offsetHeight+'px');
    }
    </style>
    </head>
    <body>
    <div id="high"></div>
    
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2005
    Posts
    132
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    V smart. cheers

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Seems to require javascript enabled in IE (for the expression style rule) ...
    Shouldn't do. Remember that percentage values for the height property require that an explicit height declaration is applied to the containing block.

    To get an element to fill the viewport vertically, both the html and body elements need to be set to 100% height, as well as any elements between body and the target element itself (though percentages that would compute to 100%, like 150% and 66.7%, would be fine, too). Note that ideally, one should use the min-height property so that the elements may expand if necessary (though IE is broken and the height property will do this anyway).

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    You could (and convention says one would) replace "/1999/REC-html401-19991224/" in that system identifier with "/html4/".

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •