Forum Moderators: not2easy
I have a really odd positioning problem between IE and all the other browsers. For some reason IE thinks differently, here is the code:
<!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>Position testing</title>
<style type="text/css">
body {
#absolute {
position:absolute;
width:100px;
height:100px;
background-color:#000099;
color:white;
overflow:auto;
}
#float {
float:left;
width:200px;
color:white;
background-color:#6699FF;
padding-top:200px;
overflow:auto;
}
</style>
</head>
<body>
<div>
<div id="absolute">absolute</div>
<div id="float">float</div>
</div>
</body>
</html>
In FF and all other browsers, the absolute DIV is layered on top of the float div, but in IE it positions it AFTER the float div (to the right).
Can anyone spot why? I am sure there is a reason for this, but just can't find it!
help!
Thanks
Phil
Thank you!
try this it works for me.
<!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>Position testing</title>
<style type="text/css">
#absolute {
width:100px;
height:100px;
background-color:#000099;
color:white;
overflow:auto;
}
#float {
float:left;
width:200px;
color:white;
background-color:#6699FF;
padding-top:200px;
overflow:auto;
}
</style>
</head>
<body>
<div>
<div id="absolute">absolute</div>
<div id="float">float</div>
</div>
</body>
</html>
Btw, I'm a newbie so take my advice with a grain of salt.
The reason I am using position:absolute on the "absolute" div is to stack the absolute DIV on top of the floated div:
<!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>Position testing</title>
<style type="text/css">
#absolute {
position:absolute;
width:100px;
height:100px;
background-color:#000099;
color:white;
overflow:auto;
}
#float {
float:left;
width:200px;
color:white;
background-color:#6699FF;
padding-top:200px;
overflow:auto;
}
</style>
</head>
<body>
<div>
<div id="absolute">absolute</div>
<div id="float">float</div>
</div>
</body>
</html>
All browsers except IE start positioning the absolute DIV from the top left of the page. IE starts positioning it after the floated DIV which just doesn't make sense to me.
Any other ideas?