Scrollbar not appearing in IE7 when CSS overflow auto is set

Recently when working on a JQuery based UI, I encountered an annoying IE 7 problem. I had a scrollable DIV setup with overflow:auto; configured in CSS. The scrollable DIV had a one child div which contained text. As the text grows in length the parent scrollable div should trigger a vertical scrollbar. This worked fine in every browser, FF, SF, IE6/8 but would not work in IE7. When you first viewed the page in IE7 the text would just cut off and the scrollbar would not be visible, however when you clicked on another page element and brought focus back to the scrollable div, the scrollbar would then appear as expected. Annoying indeed. To fix this in IE7 I simply did the following in JQuery to dynamically adjust the height when the after the DIV gained focus and it fixed the problem. Might it help you? Who knows but it worked for me.

var h = $("myScrollingDivWithOverflowAUTOset").height();

One thought on “Scrollbar not appearing in IE7 when CSS overflow auto is set

  1. You really should re-use and chain the jQuery object rather than creating a new instance repeatedly, it’ll be far more efficient. Also I’m not sure you want h-1 do you? You’re effectively shortening the div by 1 pixel since you don’t reassign h after h+1.

    var scrollDiv = $(“myScrollingDivWithOverflowAUTOset”);
    var h = scrollDiv.height();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s