Forum Moderators: not2easy

Message Too Old, No Replies

ie6 ie7 height difference to firefox

Why does firefox adds a margin when height is not forced?

         

14dgt

2:27 am on Dec 8, 2006 (gmt 0)

10+ Year Member



Hi all,

This is my first post so be gentle please...

I'm trying to eliminate tables in all future websites that we develop, but I'm having a problem with height differences between ie and ff. The problem in the code below is that the centre row(div - centre) will have varying heights depending on the data returned (so I cant force a height), but it needs to butt on to the div's above and below, which works fine in ie but there is a margin top and bottom in ff. I have searched the forum but have been unable to find a solution to this.

Thanks for any help
Steve

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--

html, body {margin:0px; padding:0px; background:#EEE; font-family:verdana; font-size:12px;}
#head {
background-color: #66FF00;
height: 50px;
width: 772px;
text-align: left;
display:block;
position: relative;
top: 0px;
}
#wrap {
position:relative;
display:block;
width: 772px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
height: 1%;
}
#centre {
position:relative;
display:block;
width: 500px;
background-color: #FFF;
}
#base {
background-color: #FFFF00;
height: 15px;
width: 500px;
display:block;
position: relative;
}
#foot {
background-color: #00CCCC;
height: 20px;
width: 500px;
display:block;
position: relative;
}
-->
</style>
</head>

<body>

<div id="wrap">
<div id="head">e</div>
<div id="centre">
<p>kkkk</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>k</p>
</div>
<div id="base">e</div>
<div id="foot">e</div>
</div>
</body>
</html>

DanA

7:13 am on Dec 8, 2006 (gmt 0)

10+ Year Member



It is a problem of uncollapsing margins.
You have to control margins (and paddings too for cross browser compatibility)
Test the stylesheet/layout with #centre p{margin:0;}

[edited by: DanA at 7:14 am (utc) on Dec. 8, 2006]

14dgt

11:03 pm on Dec 10, 2006 (gmt 0)

10+ Year Member



Thanks DanA that worked a treat...