Forum Moderators: not2easy

Message Too Old, No Replies

How to force DIV to the bottom in Firefox

Looks great in IE!

         

Cienwen

5:21 pm on May 11, 2007 (gmt 0)

10+ Year Member



Hello CSS Gurus,

I have a very complicated CSS layout and I am having trouble with Firefox and Opera. Looks great in IE (go figure!).

I have two horizontal bars of color that are 20px tall and 100% wide. They are supposed to be flush against the top of the window and the bottom of the window with the page content center in between and bumping flush against the bars of color. Got that?

So the top and bottom bars are <div>s and the page content is all wrapped in a <div>. This all works great in IE but in Firefox and Opera the bottom bar floats up the page a ways and sits behind the page content.

The short version of the HTML is

<body id="info">

<div id="topBar"></div>

<div id="pageBody">

Content….

</div>

<div id="bottomBar"></div>

</body>

The effecting CSS is

body {
margin: 0;
padding: 0;
height: 100%;
text-align: center;
color: #ccc;
font: Verdana, Arial, sans-serif;
}

#topBar {
width: 100%;
height: 20px;
margin: 0;
padding: 0;
}

#pageBody {
width: 800px;
height: 100%;
margin-right: auto;
margin-left: auto;
background-color: #000;
}

#bottomBar {
width: 100%;
height: 20px;
margin: 0;
padding: 0;
}

All of my #info CSS changes colors only.

Each page that uses this has a different height to account for different amounts of page content.

Does anyone know what’s going on here.

Thanks a bunch.

Cienwen

Cienwen

4:34 pm on May 16, 2007 (gmt 0)

10+ Year Member



Three days of reading tutorials and I've got it.

#bottomBar {
width: 100%;
height: 20px;
margin: 0;
padding: 0;
clear: both;
}

Clear! I had to clear!

Xapti

5:22 pm on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no reason to use clears here though. Not unless you're using floats. No where in your code did you use a float, so a clear wouldn't do anything. You probably didn't include all of the relevant code because the code here really wouldn't cause much problems.

Also realize widths don't need to be set to 100% on block elements (unless they are positioned or floated). By default they span the entire width of their container, which is usually better than width:100%, because width:100% sets just the element's widths to 100%, not including padding, margin, or border. So if you have any of those three greater than 0 on an element, it will span more than 100% of the container.