IE and overflow: auto

As you may of noticed, I’ve been having some problems with the “@overflow@(w3c – Overflow and clipping)”:http://www.w3.org/TR/REC-CSS2/visufx.html#overflow-clipping property and IE. Simply put, @overflow@ should define how content outside the displayable area is handled. Using the @auto@ value should display scrollbars when required – and this works perfectly on Mozilla. On IE however I couldn’t get it to work at all.

The problem is seems is that IE isn’t bright enough to work out the width of the on screen element – if I give my @pre@ blocks a width (which I can now do with a fixed-width layout) it correctly displays horizontal scrollbars and stops playing havoc with my layout. Its not all plain sailing however – when it adds the horizontal scrollbar, it doesn’t correctly resize the @pre@, and therefore also displays vertical scrollbars! Oh well, such is life…

No Trackbacks

6 Comments

  1. if you know how much of the screen it will NOT occupy (e.g. you’ve got 200px margins on each side) you can use

    <!–[If IE]>
      <style type=”text/css”>
      .overflowthingy{
        width:expression(document.body.clientWidth-400);
        overflow-x:auto;
        overflow-y:hidden
      }
      </style>
    <![endif]–>

    It’s ugly, but it works…

    Posted May 16, 2004 at 9:28 pm | Permalink
  2. Great tip – thanks Farlukar! In the end, I just assumed a fixed width for pre blocks, and IE correctly displays scrollbars, but your tip will be very useful if I go back to a liquid layout.

    Posted May 16, 2004 at 11:36 pm | Permalink
  3. i absolutely love you for that code!!! ahh ! lol absolutely great tip…i feel so stupid that i didn’t think of it haha =D

    Posted July 4, 2004 at 10:16 pm | Permalink
  4. heh – new layout ate the pre tag…

    Posted July 14, 2006 at 9:22 am | Permalink
  5. I find that this works for me in all browsers.

    pre {
    overflow: auto;
    }

    pre {
    width: 100%;
    overflow: auto;
    overflow-x: auto;
    overflow-y: hidden;
    }

    Posted January 2, 2009 at 3:44 am | Permalink
  6. Sorry, but it seems that my previous comment has been striiped of the ie conditional statements around the second code block.

    Posted January 2, 2009 at 3:45 am | Permalink

Post a Comment

Your email is never shared. Required fields are marked *

*
*