Forum Moderators: not2easy
The issue I'm having is that when the table fills the entire content-area of its parent (whether by using width: 100% or hard-coding the width in), the vertical scrollbar of the DIV containing it disappears. If the table's width is less than the total content area, but more than the content area minus the scrollbar width, I get both horizontal and vertical scrollbars (even though the vertical scrollbar is outside the content area). If the table width is less than the content area minus the scrollbar width, everything displays correctly.
The code also displays correctly in both IE6 and FireFox, in all cases mentioned above. Only IE7 has a problem.
DOCTYPE:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
CSS:
.scrollingtable {
overflow: show;
position:relative;
width: 1000px;
}
.inner {
overflow:auto;
height:9.6em;
background-color:red;
padding-right:100px;
}.scrollingtable table {
width:100%;
background-color:green;
}
HTML:
<div class="scrollingtable">
<div class="inner">
<table summary="This table lists flights arriving at Bristol International Airport." cellspacing="0" cellpadding="0">
<thead>
<tr>
<th scope="col" class="first">
Test</th>
<th scope="col">
test</th>
<th scope="col">
test</th>
<th scope="col">
test</th>
<th scope="col" class="last">
test</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" class="first">
test</th>
<th scope="col">
test</th>
<th scope="col">
test</th>
<th scope="col">
test</th>
<th scope="col" class="last">
test</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr class="alt">
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr class="alt">
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr class="alt">
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
<tr class="alt">
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
<td>
test</td>
</tr>
</tbody>
</table>
</div>
</div>
I'm working on adapting a scrolling table example by Stu Nicholls into an Asp.Net control. The original example used hardcoded widths for the table and containing DIV, but ideally I'd like to be able to set the width exactly once.
The nesting of the additional outer/inner DIV is necessary for other traits of the table, such as stationary headers and footers (omitted here for clarity).
If I give the containing div (.inner in this example) a padding equal to the width of the scrollbar, then the only thing revealed with the horizontal scrolling is the padding... Making it safe to disable horizontal scrolling.
Below are the updated CSS classes I'll be using:
.scrollingtable {
overflow: show;
position:relative;
width: 1000px;
}
.inner {
overflow:auto;
overflow-x: hidden;
height:9.6em;
background-color:red;
padding-right:20px;
}
.scrollingtable table {
width:99.9%;
background-color:green;
}