Firefox - divs and scrollbars
- houndour
- Graduate


- Joined: Nov 08, 2004
- Posts: 201
- Loc: Surrey, UK
- Status: Offline
I have a set of divs on a page which are displayed using display: block and hidden using display: none.
In firefox a div containing lots of info expands the page and the scrollbar appears. But when a div with hardly any info is chosen the page height stays the same as if the old info was there...and the scroll bar stays.
In IE6 it shrinks the page like you would expect and the scrollbar disappears like you would expect.
Any clues as to what I need to look into here?
I wouldn't be _that_ fussed but the issue is more with the way the page has been designed, and it has a footer...so the footer once pushed off the page stays off...if you see what I mean.
In firefox a div containing lots of info expands the page and the scrollbar appears. But when a div with hardly any info is chosen the page height stays the same as if the old info was there...and the scroll bar stays.
In IE6 it shrinks the page like you would expect and the scrollbar disappears like you would expect.
Any clues as to what I need to look into here?
I wouldn't be _that_ fussed but the issue is more with the way the page has been designed, and it has a footer...so the footer once pushed off the page stays off...if you see what I mean.
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
May 5th, 2006, 8:55 am
- roarmeow
- Professor


- Joined: Oct 12, 2004
- Posts: 861
- Loc: BKNY
- Status: Offline
- houndour
- Graduate


- Joined: Nov 08, 2004
- Posts: 201
- Loc: Surrey, UK
- Status: Offline
- houndour
- Graduate


- Joined: Nov 08, 2004
- Posts: 201
- Loc: Surrey, UK
- Status: Offline
OK, excuse the crude sample....I've just knocked this up quickly to show you what I mean:
If you try the above in IE, click on the "three" button the text should go off the page and the left hand column expands with it. Then click on button "one" and the page then resizes to fit.
If you try the same in Firefox, when you click back on "one" after clicking on "three" the page stays long with a big scrollbar...so the footer would be way off the page.
Hope that makes a little more sense?
Code: [ Select ]
<html><head><title>Test</title>
<style>
body {
background: #e1b107;
}
body, p, td, ol, ul {
font-family: arial, helvetica;
font-size: 14px;
font-weight: bold;
color: #ffffff
}
#main, #left{
background: #2f2f2f;
}
#main {
text-align: center;
}
.error {
color: #e30b00;
font-size: 12px;
}
.curved_bg {
background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
}
#header_right {
background: url(images/header_bg.gif) 0 0 no-repeat;
}
</style>
<script>
function show( x )
{
document.getElementById( 'one' ).style.display = "none";
document.getElementById( 'two' ).style.display = "none";
document.getElementById( 'three' ).style.display = "none";
document.getElementById( x ).style.display = "block";
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
<tr>
<td valign="top" width="280">
<table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td height="20">Top Image</td>
</tr>
<tr>
<td id="logo" height="77">Logo</td>
</tr>
<tr>
<td valign="top">Nav bar</td>
</tr>
<tr>
<td height="20" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
<td width="20"> </td>
<td valign="top" width="700">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr>
<td>Header - <input type="button" value="one" onclick="show( 'one' );" /><input type="button" value="two"
onclick="show( 'two' );" /><input type="button" value="three" onclick="show( 'three' );" /></td>
</tr>
<tr>
<td colspan="2" class="curved_bg" align="center" height="100%" valign="top">
<div id="one" style="display: block;">Div 1<br/></div>
<div id="two" style="display: none;" >Div
2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
<div id="three" style="display: none;" >Div
3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
/><br/></div>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</body>
</html>
<style>
body {
background: #e1b107;
}
body, p, td, ol, ul {
font-family: arial, helvetica;
font-size: 14px;
font-weight: bold;
color: #ffffff
}
#main, #left{
background: #2f2f2f;
}
#main {
text-align: center;
}
.error {
color: #e30b00;
font-size: 12px;
}
.curved_bg {
background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
}
#header_right {
background: url(images/header_bg.gif) 0 0 no-repeat;
}
</style>
<script>
function show( x )
{
document.getElementById( 'one' ).style.display = "none";
document.getElementById( 'two' ).style.display = "none";
document.getElementById( 'three' ).style.display = "none";
document.getElementById( x ).style.display = "block";
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
<tr>
<td valign="top" width="280">
<table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td height="20">Top Image</td>
</tr>
<tr>
<td id="logo" height="77">Logo</td>
</tr>
<tr>
<td valign="top">Nav bar</td>
</tr>
<tr>
<td height="20" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
<td width="20"> </td>
<td valign="top" width="700">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr>
<td>Header - <input type="button" value="one" onclick="show( 'one' );" /><input type="button" value="two"
onclick="show( 'two' );" /><input type="button" value="three" onclick="show( 'three' );" /></td>
</tr>
<tr>
<td colspan="2" class="curved_bg" align="center" height="100%" valign="top">
<div id="one" style="display: block;">Div 1<br/></div>
<div id="two" style="display: none;" >Div
2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
<div id="three" style="display: none;" >Div
3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
/><br/></div>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</body>
</html>
- <html><head><title>Test</title>
- <style>
- body {
- background: #e1b107;
- }
- body, p, td, ol, ul {
- font-family: arial, helvetica;
- font-size: 14px;
- font-weight: bold;
- color: #ffffff
- }
- #main, #left{
- background: #2f2f2f;
- }
- #main {
- text-align: center;
- }
- .error {
- color: #e30b00;
- font-size: 12px;
- }
- .curved_bg {
- background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
- }
- #header_right {
- background: url(images/header_bg.gif) 0 0 no-repeat;
- }
- </style>
- <script>
- function show( x )
- {
- document.getElementById( 'one' ).style.display = "none";
- document.getElementById( 'two' ).style.display = "none";
- document.getElementById( 'three' ).style.display = "none";
- document.getElementById( x ).style.display = "block";
- }
- </script>
- </head>
- <body>
- <table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
- <tr>
- <td valign="top" width="280">
- <table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
- <tbody><tr>
- <td height="20">Top Image</td>
- </tr>
- <tr>
- <td id="logo" height="77">Logo</td>
- </tr>
- <tr>
- <td valign="top">Nav bar</td>
- </tr>
- <tr>
- <td height="20" bgcolor="#ff0000">Bottom Image</td>
- </tr>
- </tbody></table>
- </td>
- <td width="20"> </td>
- <td valign="top" width="700">
- <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
- <tr>
- <td>Header - <input type="button" value="one" onclick="show( 'one' );" /><input type="button" value="two"
- onclick="show( 'two' );" /><input type="button" value="three" onclick="show( 'three' );" /></td>
- </tr>
- <tr>
- <td colspan="2" class="curved_bg" align="center" height="100%" valign="top">
- <div id="one" style="display: block;">Div 1<br/></div>
- <div id="two" style="display: none;" >Div
- 2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
- <div id="three" style="display: none;" >Div
- 3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
- test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
- r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
- /><br/></div>
- </td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#ff0000">Bottom Image</td>
- </tr>
- </tbody></table>
- </td>
- </tr>
- </tbody></table>
- </body>
- </html>
If you try the above in IE, click on the "three" button the text should go off the page and the left hand column expands with it. Then click on button "one" and the page then resizes to fit.
If you try the same in Firefox, when you click back on "one" after clicking on "three" the page stays long with a big scrollbar...so the footer would be way off the page.
Hope that makes a little more sense?
- gonzoka
- Student


- Joined: Jul 30, 2005
- Posts: 75
- Loc: Bristol, UK
- Status: Offline
- Katmandu
- Student


- Joined: May 02, 2006
- Posts: 69
- Loc: Spain, Mallorca
- Status: Offline
gonzoka wrote:
I've also found that when using display to hide and show divs in firefox, the page uses the largest one, and doesnt shrink back too. Would be interested in finding a solution for this!
Ok, I'm not big at Javascript, but I noticed that actually the element not shrinking back is the table cell and not the div, because the script changes the div displayed but does not change the <td>. Try changing from table design to div design.
I have tested a few options but only came up with the following code. The problem is that the resulting <div id="one"> does not expand to the bottom on default. But if you don't mind this it could be a solution for you.
Just deleted the Table the div's where in and changed them by divs
Code: [ Select ]
<html><head><title>Test</title>
<style>
body {
background: #e1b107;
}
body, p, td, ol, ul {
font-family: arial, helvetica;
font-size: 14px;
font-weight: bold;
color: #ffffff
}
#main, #left{
background: #2f2f2f;
}
#main {
text-align: center;
}
#one, #two, #three{
text-align:center;
color:#FFFFFF;
}
#bottom {
background-color:red;
color:white;
}
.error {
color: #e30b00;
font-size: 12px;
}
.curved_bg {
background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
}
#header_right {
background: url(images/header_bg.gif) 0 0 no-repeat;
}
</style>
<script>
function show( x )
{
document.getElementById( 'one' ).style.display = "none";
document.getElementById( 'two' ).style.display = "none";
document.getElementById( 'three' ).style.display = "none";
document.getElementById( x ).style.display = "block";
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
<tr>
<td valign="top" width="280">
<table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td height="20">Top Image</td>
</tr>
<tr>
<td id="logo" height="77">Logo</td>
</tr>
<tr>
<td valign="top">Nav bar</td>
</tr>
<tr>
<td height="20" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
<td width="20"> </td>
<td valign="top" width="700">
<div>Header - <input type="button" value="one" onClick="show( 'one' );" /><input type="button" value="two"
onclick="show( 'two' );" /><input type="button" value="three" onClick="show( 'three' );" /></div>
<div style="background-color:#2f2f2f;">
<div id="one" style="display: block;">Div 1</div>
<div id="two" style="display: none;" >Div
2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
<div id="three" style="display: none;" >Div
3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
/><br/></div></div>
<div id="bottom">Bottom Image</div>
</td>
</tr>
</tbody></table>
</body>
</html>
<style>
body {
background: #e1b107;
}
body, p, td, ol, ul {
font-family: arial, helvetica;
font-size: 14px;
font-weight: bold;
color: #ffffff
}
#main, #left{
background: #2f2f2f;
}
#main {
text-align: center;
}
#one, #two, #three{
text-align:center;
color:#FFFFFF;
}
#bottom {
background-color:red;
color:white;
}
.error {
color: #e30b00;
font-size: 12px;
}
.curved_bg {
background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
}
#header_right {
background: url(images/header_bg.gif) 0 0 no-repeat;
}
</style>
<script>
function show( x )
{
document.getElementById( 'one' ).style.display = "none";
document.getElementById( 'two' ).style.display = "none";
document.getElementById( 'three' ).style.display = "none";
document.getElementById( x ).style.display = "block";
}
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
<tr>
<td valign="top" width="280">
<table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td height="20">Top Image</td>
</tr>
<tr>
<td id="logo" height="77">Logo</td>
</tr>
<tr>
<td valign="top">Nav bar</td>
</tr>
<tr>
<td height="20" bgcolor="#ff0000">Bottom Image</td>
</tr>
</tbody></table>
</td>
<td width="20"> </td>
<td valign="top" width="700">
<div>Header - <input type="button" value="one" onClick="show( 'one' );" /><input type="button" value="two"
onclick="show( 'two' );" /><input type="button" value="three" onClick="show( 'three' );" /></div>
<div style="background-color:#2f2f2f;">
<div id="one" style="display: block;">Div 1</div>
<div id="two" style="display: none;" >Div
2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
<div id="three" style="display: none;" >Div
3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
/><br/></div></div>
<div id="bottom">Bottom Image</div>
</td>
</tr>
</tbody></table>
</body>
</html>
- <html><head><title>Test</title>
- <style>
- body {
- background: #e1b107;
- }
- body, p, td, ol, ul {
- font-family: arial, helvetica;
- font-size: 14px;
- font-weight: bold;
- color: #ffffff
- }
- #main, #left{
- background: #2f2f2f;
- }
- #main {
- text-align: center;
- }
- #one, #two, #three{
- text-align:center;
- color:#FFFFFF;
- }
- #bottom {
- background-color:red;
- color:white;
- }
- .error {
- color: #e30b00;
- font-size: 12px;
- }
- .curved_bg {
- background: #2f2f2f url(images/main_top_bg.gif) 0 0 no-repeat;
- }
- #header_right {
- background: url(images/header_bg.gif) 0 0 no-repeat;
- }
- </style>
- <script>
- function show( x )
- {
- document.getElementById( 'one' ).style.display = "none";
- document.getElementById( 'two' ).style.display = "none";
- document.getElementById( 'three' ).style.display = "none";
- document.getElementById( x ).style.display = "block";
- }
- </script>
- </head>
- <body>
- <table border="0" cellpadding="0" cellspacing="0" height="100%" width="1000">
- <tr>
- <td valign="top" width="280">
- <table id="left" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
- <tbody><tr>
- <td height="20">Top Image</td>
- </tr>
- <tr>
- <td id="logo" height="77">Logo</td>
- </tr>
- <tr>
- <td valign="top">Nav bar</td>
- </tr>
- <tr>
- <td height="20" bgcolor="#ff0000">Bottom Image</td>
- </tr>
- </tbody></table>
- </td>
- <td width="20"> </td>
- <td valign="top" width="700">
- <div>Header - <input type="button" value="one" onClick="show( 'one' );" /><input type="button" value="two"
- onclick="show( 'two' );" /><input type="button" value="three" onClick="show( 'three' );" /></div>
- <div style="background-color:#2f2f2f;">
- <div id="one" style="display: block;">Div 1</div>
- <div id="two" style="display: none;" >Div
- 2<br/>test<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>testtest<br/><br/><br/>test</div>
- <div id="three" style="display: none;" >Div
- 3<br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>
- test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<b
- r/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br/><br/>test<br/><br
- /><br/></div></div>
- <div id="bottom">Bottom Image</div>
- </td>
- </tr>
- </tbody></table>
- </body>
- </html>
- houndour
- Graduate


- Joined: Nov 08, 2004
- Posts: 201
- Loc: Surrey, UK
- Status: Offline
- Sakthi
- Born


- Joined: Aug 24, 2007
- Posts: 4
- Loc: Tamil Nadu - India
- Status: Offline
- routhu
- Beginner


- Joined: Feb 28, 2007
- Posts: 47
- Loc: India
- Status: Offline
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 10 posts
- Users browsing this forum: No registered users and 163 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
