views:

100

answers:

2

I want to display a page with no scrollbar (height:100%). I have read suggestions to add this argument to html and body. But it does not work as I expect. In FF indeed I do not see a scrollbar. But in IE7 and 8 (Standards mode) there is a scrollbar. In Quirks mode it works as expected. Please take a look at this:

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"&gt;
    <!-- saved from url=(0053)http://apptools.com/examples/tables/standardscss.html -->
    <html><head><title>standards compliance mode with css rendering</title>
    <meta content="text/html; charset=iso-8859-1" http-equiv=content-type>
    <meta content=no http-equiv=imagetoolbar>
    <meta name=mssmarttagspreventparsing content=true>
    <style type=text/css>body {
        padding-bottom: 0px; background-color: #fff; margin: 0px; padding-left: 0px; padding-right: 0px; color: #000; padding-top: 0px
    }
    table {
        border-bottom: #008 1px solid; border-left: #008 1px solid; border-top: #008 1px solid; border-right: #008 1px solid
    }
    html {
        height: 100%
    }
    body {
        height: 100%
    }
    .fullheight {
        height:100%
    }
    </style>

    <meta name=generator content="mshtml 8.00.6001.18876"></head>
    <body>
    <table width=450 bgcolor=#ccccff align=center height="100%">
      <tbody>
      <tr>
        <td colspan="2" height="200px">
          <p>paragraph</p>
    </td></tr>
      <tr class="fullheight"><td >
      <p>paragraph</p>
      </td>
      <td>
      <p>paragraph</p>
      </td>
      </tr>


      </tbody></table></body></html>
+1  A: 

Umm... what you're asking can get into complicated territory, but I'd start with eliminating inconsistencies in your code. For example:

  • Your table is 100% height.
  • Inside, you have a 200px high <td> inside one <tr>
  • Inside, you also have a 100% high second <tr>

So you're telling the code that 100% + 200px = 100%. That fails logically, although you might want to hack your code that way sometimes.

First, try adjusting the properties so that they work logically and try to reduce your code to greater simplicity, and then work your way up from there. After that, if a scrollbar still appears, you'll probably need to start tweaking with negative margins. This will get so "intimate" with your code that frankly anyone advising you would need a clear sense of your objectives, rather than advising on individual code elements.

Tom
As far as I know the height percentage that an element must take up in its _parent_ container. So, my thought was for the table to be 100% height (of the body), the first one of the rows to be height:200px (of the table) and the second one take up the remaining height (of the table). If the "equation" is not correct, how am I going to achieve the second row to be as I expect?
Markos Fragkakis
I see....... on rough visual estimation, when the scrollbars appear, would you say that the "space" that appears at the bottom of the page (i.e. the scrollable area) is 200px?
Tom
Yes, it is about (if not exactly) 200px.
Markos Fragkakis
Ok, so this is what I meant by negative margins. This is going to get potentially frustrating, or maybe not. Try adding {margin-bottom: -200px} for the table. If that doesn't work, try giving the same property to your <body>..... it's going to get silly like this. Here's one link I've learnt a lot from: http://ryanfait.com/sticky-footer/ .... it uses just these techniques. Good luck.
Tom
The margin-bottom: -200px indeed does work for IE. But it makes the scrollbar appear in FF. I will experiment some more today and tomorrow. If i find anything I will post. Thanks Tom!
Markos Fragkakis
Markos.... glad it was of help. Remember to keep those negative margins in mind when you develop the page further, as sometimes additional margins and paddings elsewhere can mess it up and you'll need to tweak further.
Tom
+1  A: 

If the problem is the scrollbar, you can use the CSS "overflow" attribute in order to force the behavior:

  • visible: the overflow is not clipped. It renders outside the element's box. This is default;
  • hidden: the overflow is clipped, and the rest of the content will be invisible;
  • scroll: the overflow is clipped, but a scroll-bar is added to see the rest of the content;
  • auto: if overflow is clipped, a scroll-bar should be added to see the rest of the content.
Davmuz