views:

62

answers:

4

Why does this create a veritcal scrollbar in IE6, IE7 and IE8? How to avoid it?

(I had a real applet in there, but I discovered that this heavily mutilated one gave the same result and helps simplify the test case)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html>
<head>
    <title>Why vertical scrollbar in IE?</title>


    <style>
        HTML, BODY {
            height: 100%;
        }

        BODY {
            padding:0;
            margin:0;
        }

        /* And yes I can use this, but I'd rather not
        BODY {
            overflow-y: hidden;
        }
        */
    </style>
</head>
<body>
     <APPLET  WIDTH = "100%" HEIGHT = "100%"></APPLET>
</body>
</html>

Above also available as http://www.morch.com/download/ieVerticalScrollbars.html

A: 

Try bringing the height down to 99% or 98%. Or try throwing in some more thorough reset CSS. Don't ever use overflow-y on a body element. Terrible usability.

Kyle
If I set a height of 99% then there are scrollbars if the window is sufficiently low. Make the window higher and the scrollbars disappear, but it also becomes noticable that it doesn't stretch all the way to the bottom of the window.I don't understand the general rule of "Don't ever use overflow-y on a body element. Terrible usability." In my case I wrote the applet and know it will never ever become bigger.In reality I'm setting it with jQuery because of other layout constraints and there subtracting exactly 3 pixels avoids scrollbars.I already tried using YUIs reset CSS. Didn't help.
Peter V. Mørch
A: 

Add position: absolute; to the applet's style.

BalusC
Thanks, that works. And you were first with a working answer. However, I accepted the other answer, because it has just that little bit more explanation that helps me understand _why_ it works.Sorry for taking some time to respond to your answer, I've been on vacation (and they are nice and long here in Denmark! :-D)
Peter V. Mørch
A: 

Thing 1 -- CSS/overflow

Here are the CSS settings you can work with (if they help): http://www.w3schools.com/Css/pr_pos_overflow.asp

Thing 2 -- CSS-erize the scrollbar itself (i.e., turn it completely white, or whatever works for your page.: http://www.draac.com/css/csstricks.html (scroll down a ways)

dave
A: 
applet {
    display: block;
}

To prevent rendering the applet as an inline-element, which enforces line-height rendering.

Pumbaa80
Yup, this worked like a charm! I'll accept this answer, as there is an explanation as to why too.
Peter V. Mørch