Web Hosting Talk







View Full Version : IE firefox Float issue - displays differently


o-dog
02-04-2006, 03:57 PM
Hi, im having some trouble with the way ie and ff deal with floats. As i understand it (and not very well at that!), firefox deals with them correctly whereas and ie doesnt. What i want is to display the text the way internet explorer does (but in firefox!). I guess im not coding correctly :'(. How can i get it so both browsers look the same with the 10px padding?

The code is below:

<!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" >

<style type="text/css" media="screen">

* {
padding:0;
margin:0;
}

#container {
position:relative;
text-align:left;
margin: 0 auto;
width: 500px;
margin-top:20px;
border: dashed 1px black;
}

#navlist {
font-weight:bold;
}

#navlist ul {
padding-left: 0;
margin-left: 0;
background-color: #ABCA7A;
float: left;
width: 100%;
border-bottom: 1px solid black;
}

#navlist ul li
{
display: inline;
}

#navlist ul li a
{
color: #393939;
text-decoration: none;
float: left;
border-right: 1px solid black;
}

#content
{
padding: 10px 10px 10px 10px;
}

</style>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<div id="container">
<div id="navlist">
<ul>
<li><a href="#">first</a></li>
<li><a href="#">second</a></li>
</ul>
</div>
<div id="content">
<p>this text should have 10px padding all the way round!</p>
</div>
</div>
</body>
</html>


Ive uploaded the site here (http://www.monsterserve.net/menutest.html).

Is there any way to do this with div id's (i am using div id's because of the way im laying my site out, much like css zen sites).

TIA.

Chris

Graphicism
02-04-2006, 04:55 PM
Well your right, FF displays it correctly, therefor design to FF, and double check in IE.

Looking at your code you are using relative, don't. For your container just use something like - height: 100%; width: 100%; and the boxes you place in side can just float - width: 500px; float: left;

Basically if you put the text in it's own div and apply the padding to the div it will work.

Hope this makes sense.

NyteOwl
02-04-2006, 05:16 PM
You also haven't specified a DOCTYPE which puts browsers into "quirks" mode. You'll get more predictable results by telling the the specification they should follow. IE's float behaviour , as usual, is different than everyone else.

Graphicism
02-05-2006, 02:13 AM
He has specified a DOCTYPE and regardless that isn't the problem. The problem isn't with Internet explorer nor is it with floats, it just has to be done correctly. Lets for a second say the problem is IE (and not the code) floats will work better than relative and absolute anyway.

Uncle Bob
02-05-2006, 04:01 AM
Chuck all the "float:left" in the stylesheet, and it'll work perfectly. Or if you prefer to keep them, put one in for the "#content" style as well. Doing that however, makes the dotted line disappear in FF.

NyteOwl
02-05-2006, 06:07 PM
hmmm I could have sworn there was no doctype.oh well. sorry. And yes, IE does have a different way of managing floats.