Results 1 to 11 of 11

Thread: (CSS) defining a div's height relitave to the window size

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    (CSS) defining a div's height relitave to the window size

    I am trying to set a divs height to 100% but it is not listening.
    Code:
    <div style="width:100%;height:100%;overflow:auto;text-align:center;background:red;">
    (i put the style for the sake of simplifying this post). If i set it to a specific size (not %) it will do it. Can anyone tell my why it wont work or another way to go about it?
    thanks
    michael
    Last edited by msimmons; Apr 19th, 2002 at 01:29 PM.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  2. #2

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    ok, it looks like if the 'containing block' (containing the item w/a height%) doesn't have a height specified then a %height is treated like auto... the containg block is my <body> so what to do?
    thanks michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  3. #3
    scoutt
    Guest
    put the whole thing in a table at 100%

  4. #4

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    man... now why didnt i think of that... i wasted all day thinking (or avoiding) on that prob.
    thanks!
    michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  5. #5
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          .Container {
            height: 100%;
            width: 100%;
            background-color: red;
            color: black;
          }
        </style>
      </head>
      <body>
        <div class="Container">
        </div>
      </body>
    </html>
    This works, and you don't have to hork your page with a table. Also, try setting the padding and margins to zero, or making the div position: absolute, so it won't be contained by the body block. For more fun, try setting the dimensions to 110%.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  6. #6
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Sorry, had too much fun...

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          body {
            padding: 0px;
          }
          .Container {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            background-color: red;
            color: black;
          }
        </style>
      </head>
      <body>
        <div class="Container">
        </div>
      </body>
    </html>
    That is the same as setting the body's background-color to red.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  7. #7

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    The 'content' div idea didnt have the desired effect. I am trying to get the overflow value to work on a div so that when the content is more than the size of the window (this is a popup that is dynamic so I never know how much data is going to be inside) it creates a scrollbar.
    The table idea did work but I prefer divs.
    thanks,
    Michael

    ps sorry about the late response... being the only comp person in the dept I jump from proj to proj.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  8. #8
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    And "auto"and "scroll" don't work for "overflow" values?
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  9. #9

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Code:
    <div style="width:100%;height:100%;overflow:auto;text-align:center;">
    works when inside of a 100% table but that was the only way I could get it to work.
    Michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  10. #10
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Dude, I have no idea what you are trying to do then.

    If this doesn't work, then explain again what you want.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>Test Page</title>
        <style type="text/css">
          body {
            padding: 0px;
          }
          .Container {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            background-color: red;
            color: black;
            overflow: auto;
            text-align: center;
          }
        </style>
      </head>
      <body>
        <div class="Container">
          <span>Sample Text</span>
        </div>
      </body>
    </html>
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  11. #11

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    When I use the example you are posting it works perfectly but when I impliment it into my existing page the scrollbars appear late and the down arrow is just off screen. It's working fine w/the table so no worries.
    Thanks
    Michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

Posting Permissions

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



Click Here to Expand Forum to Full Width