Forum Moderators: not2easy

Message Too Old, No Replies

Overflow div makes browser scrollbars large

Large table inside div overflow makes browser scrollbars work

         

citycrew

7:49 am on Sep 21, 2009 (gmt 0)

10+ Year Member



Hi People,

I have a div with overflow: auto set and max-height: 600px. Inside that I have a table that has hundreds of rows. The scrollbar on the overflowed div works fine, but the browsers scrollbars also show the length of the table inside and I can scroll well past the bottom of my page, even though there is nothing showing.

Anyone got any ideas?

Thanks in advance.

Code:

<div class="styledBox">
<div style="overflow: auto; max-height: 600px">
<table>
<thead><tr>
<th>&nbsp;</th>
<th>Name</th>
</tr></thead>
<tbody>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
.... MANY ROWS PAST THE END OF THE PAGE
</tbody></table>
</div>
</div>

swa66

8:23 am on Sep 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What browser(s) are you struggling with ?

citycrew

9:24 am on Sep 21, 2009 (gmt 0)

10+ Year Member



Sorry I forgot to mention the browser, it's firefox. I just tested it in IE7 and it seems to do the same thing.

D_Blackwell

2:56 pm on Sep 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Edits in blue. Should work across the board as long as it doesn't interfere with some other element where you do want the page to scroll.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
overflow: hidden;
}
</style>

</head>
<body>
<div class="styledBox">
<div style="overflow: auto; height: 600px;">
<table>
<thead><tr>
<th>&nbsp;</th>
<th>Name</th>
</tr></thead>
<tbody>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
<tr>
<td>content 1</td>
<td>content 2</td>
</tr>
.... MANY ROWS PAST THE END OF THE PAGE
</tbody>
</table>
</div>
</div>
<!--##########
I have a div with overflow: auto set and max-height: 600px. Inside that I have a table that has hundreds of rows. The scrollbar on the overflowed div works fine, but the browsers scrollbars also show the length of the table inside and I can scroll well past the bottom of my page, even though there is nothing showing.
-->
</body>
</html>

citycrew

9:57 pm on Sep 21, 2009 (gmt 0)

10+ Year Member



Thanks D_Blackwell,

Unfortunately the rest of the page needs to scroll as the entire content, including the scrolling div, is about 2 browser pages long.

I actually have two radio buttons on the page and when one is selected it displays the above mentioned overflow div. So when no radio button is selected the browser page scrolls fine its two pages fine. When you select one of the radio buttons and it displays the overflow div, the page scrollbar goes small and you can scroll well beyond the bottom of the page.

I guess I'm more curious if this is a bug in my css or actually how browsers render this styling. If it's the latter then at least I know I don't have to check over my code.

Any help is appreciated.

citycrew

10:19 pm on Sep 21, 2009 (gmt 0)

10+ Year Member



Hmm... Something strange is happening. It's working properly now with no browser scrollbar change.

I will look into this more and post if I accidentally found a solution.

citycrew

10:26 pm on Sep 21, 2009 (gmt 0)

10+ Year Member



I know what it was now. I was using a mootools script to pretty up checkboxes and make them stand out. I turned the script off for that table and it works. Strange thing was I'm sure I turned off all scripts when initially testing for this bug... as you do.

Sorry for the false alarm.