I have a table (with a scroll bar) nested inside another table. Outer table has no scroll bar.
Outer table's width is set to 100% of the browser's client area width. There is a minimum width to the table, but we need not get into that, because it doesn't contribute to the issue at hand.
The column widths of both table are percentages to make them dynamically re-sizable when browser width is changed.
Because the native scroll bar width is 17px (google search), the inner table table's columns become understandably misaligned progressively shifted more and more to the left as one pans to the right.
I have 8 columns visible initially. There are 72 more hidden columns to the right. I use jquery to hide and show different sets of columns, 12 at a time. But only the initial display has 8 columns.
I can't just give different/smaller column width percentage to the inner table because the scroll bar does not re-size itself dynamically along with the table when the browser is re-sized.
I tried to assign widths of the inner table with the CSS calc() function; example calc((100% + 17px) * 10.5%) for all columns except the rightmost one. That one will bear the brunt of the scroll bar (that is OK).
100% is the width of the inner table, of course; which in turn is 100% of the outer table
17px is the width of the native scroll bar
10.5% is the width of the columns of the outer table
But this gives me very large first column width, while the rest are squeezed together.
I tried different formulas with calc() to no avail...as in, different and varied results, but still misaligned.
I need to mention that re-adjusting the column widths dynamically with jquery/javascript proved to be slow and unusable, due to the number of columns involved.
Here is what I would like to have:
col 1 | col 2 | col 3 | col 4 | col 5 | col 6 | col 7 | col 8 | -------------------------------------------------------------------------------- value1 | value2 | value3 | value4 | value5 | value6 | value7 | value8 | ... |... |... |... |... |... |... |... | -------------------------------------------------------------------------------- value |value |value |value |value |value |value |value |↑| ... |... |... |... |... |... |... |... |⁞| ... |... |... |... |... |... |... |... |⁞| ... |... |... |... |... |... |... |... |↓| -------------------------------------------------------------------------------- ... |... |... |... |... |... |... |... | ... |... |... |... |... |... |... |... | ... |... |... |... |... |... |... |... |
The section in the middle is the inner table (with a scroll bar)
But here is what I get:
col 1 | col 2 | col 3 | col 4 | col 5 | col 6 | col 7 | col 8 | -------------------------------------------------------------------------------- value1 | value2 | value3 | value4 | value5 | value6 | value7 | value8 | ... |... |... |... |... |... |... |... | -------------------------------------------------------------------------------- value |value |value |value |value |value |value |value |↑| ... |... |... |... |... |... |... |... |⁞| ... |... |... |... |... |... |... |... |⁞| ... |... |... |... |... |... |... |... |↓| -------------------------------------------------------------------------------- ... |... |... |... |... |... |... |... | ... |... |... |... |... |... |... |... | ... |... |... |... |... |... |... |... |
The simulation is not exact, but you get the drift. The columns widths of the inner table are equal to each other, but the simulation, like I said, is a bit off.