9

A div, containing a table has the following CSS styling:

#formulaAlts {
    float: right;   
    height: 200px;
    overflow: auto;
}

This makes it so that when the table is >200px, a scrollbar appears only for the table and the other elements on the page stay put. Great!

Now for our friend IE...
In IE, the element spawns the vertical scrollbar without growing the containing element. To "solve" this, a horizontal scrollbar is created.
That sucks. And I don't want it to suck...

Any ideas?

--EDIT--
I found out that the line

overflow-x: hidden;

forces IE to ignore the horizontal scrollbar. This is better.. but not quite there because now part of my table is invisble.

2
  • Can you not set the width on the containing div?
    – Prestaul
    Oct 30, 2008 at 14:42
  • yes, I could. But I don't know the width yet. It depends on the width of the values. Nov 3, 2008 at 9:13

1 Answer 1

2

Careful.

overflow-x

isn't the most widely supported attribute out there.

I tend to go with a containing div with some right padding:

CSS:

div.scroll {
  overflow:auto;
  padding-right:6px;
  /* I've found 6px to be just right my purposes, but try others*/
}

EDIT: You'll need to add a height attribute somewhere for this to work! I usually have a default set in the div.scroll declaration then tweak that for specific cases (most). HTML:

<div class="scroll" >
  <table>
  <!-- your table stuff in here -->
  </table>
</div>
2
  • Thanks for the reply. I did something similar, but used the *-hack so only IE sees it. Hate it, but until I find a better way, this will have to do. Oct 30, 2008 at 14:49
  • Hm, what do you mean by "You'll need to add a height attribute somewhere for this to work"? I'm trying to solve this problem for a few days already, and so far none of the solutions suggested on Internet worked for me... :( Apr 11, 2009 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.