Forum Moderators: not2easy
ie keeps taking one of my divs and starting it below a floated div to its left. firefox doesn't do this, and frankly, those are the only two browsers on this machine :) the rogue div ends up positioned, sized and aligned correctly except for that it's entirely too far down the page [as it's beginning below the nav column].
everything's done as includes in php, so the layout is really just a set of eight or so divs that hold everything where it should be. the issue seems to be between the nav column, floated on the left side, and the "main" div, which holds the content ... obviously on the right. you'll notice i'm not floating the content, i'm just telling it how much space to take up. here's the css for those two divs, cos that's all i can think to give you for now. if you want more, i'll hand it over. thanks so much for your anticipated suggestions!
#navcol {
float: left;
height: auto;
width: 130px;
margin-top: 20px;
padding: 0px;
}
#main {
height: auto;
width: 600px;
margin-left: 150px;
padding-top: 11px;
}
i tried a bunch of things like hiding overflow for navcol, floating main to the right etc ... i even did my homework and read through some posts on this [and other] forums before posting, but i feel i'm at a bit of an impasse. sorry for the long post!
#navcol surrounded by another division that #main is not? Because if it is, it is most likely because the parent container of the float, when hasLayout is triggered (e.g. explicitly setting a width, or height) it will acknowledge the dimensions of its child element and size accordingly (and, for a kick in IE’s guts, incorrectly. It isn’t meant to do that.)
Which would mean a block-level element that isn’t floated will be taking up all the width next to the floated element, and the non-floated
#main will have to sit down below the #navcol (and its parent.) Can you post some sample HTML that replicates the problem with the CSS you posted?
guessing.. have you got these two divs wrapped in a container div set at 750px wide? and is this only IE5.x/6, and what's your Doctype if any
my guess would be that you've fallen foul of the 3px jog and IE's quirky float model. One suggestion would be to use a wrapper div, and float the #main div too
e.g.
CSS:
#wrap {
width: 750px; /* IE will contain floats with this */
overflow: auto; /* compliant browsers will contain floats with this */
background: #eee;
}#navcol {
float: left;
width: 130px;
background: #dad;
color: #fff;
}#main {
width: 600px;
float: right;
/* no margin should be required if floated right instead */
background: #008;
color: #fff;
}p {
margin: 0.5em 0; /* IE needs explicit margins inside floated elements */
}HTML:
<div id="wrap">
<div id="navcol"><p>navigation column<br>nav<br>nav</p></div>
<div id="main"><p>main content column</p></div>
</div>
is that close? if not, and there is more to the layout, please post your outline layout HTML and tell us yur Doctype
thanks
one thing i'm seeing is that the
margin tag on #main seems to be controlling the positioning of the entire wrapping div in ie, which i have as #box. that's rather strange to me. in response to setek, perhaps i'm not fully understanding the hasLayout schema, if that's a word i can use for it. i read an msdn article about it ... maybe i'm just slow ;) as far as your suggestions, suzyuk, the code you posted rendered beautifully by itself, but when i integrated it into my stylesheets, they killed it. i had the same problem i had originally in ie, not to mention that the whole page moved to the left. in ff,
#main jumped down below #navcol and justified itself left, so lord knows what i've done :) i think what i'll do is just post the entire contents of the two stylesheets [one for layout, one for styling] and the html for the index page, if that's not too much.
oh, as far as doctype, there's actually no doctype specified in the header of the php files [the whole page], but the doctype specified in the html files that are included in
#main are xhtml 1.0 trans, if that helps at all. thanks to both of you so so much for your help. i'll keep banging away at it over here and i'll let you know if i get anywhere.
i'll post the code shortly!
#viewport {
height: auto;
width: auto;
overflow: auto;
}
#box {
height: auto;
width: 760px;
overflow: none;
}
#header {
width: 100%;
height: 120px;
margin: 0px;
padding: 0px;
}
/* this one's only for one page, so don't worry too much about it */
#mmheader {
margin: 0px;
padding: 0px;
height: 100px;
width: 100%;
clear: none;
}
#staticnav {
width: 100%;
height: 34px;
padding: 2px;
}
#navcol {
float: left;
height: auto;
width: 130px;
margin-top: 20px;
padding: 0px;
overflow: hidden;
}
#subnav {
float: left;
height: auto;
width: 130px;
margin: 0px;
margin-top: 30px;
padding: 0px;
}
/* this div is hidden and pops out thanks to a bit of java. i hope it's not what's breaking things */
#updates {
display: block;
width: 100%;
height: auto;
margin: 0px;
padding: 0px;
border: solid 1px #000;
}
#main {
height: auto;
width: 600px;
margin: 150px;
padding-top: 11px;
}
#footer {
clear: both;
height: auto;
width: 100%;
}
<body>
<div align="center" id="viewport">
<div align="left" id="box">
<div id="header">
<?php include('include/header760.php');?>
</div>
<div id="staticnav">
<?php include('include/static.html');?>
</div>
<div id="recupd">
<?php include('include/updates.php');?>
</div>
<div id="navcol">
<?php include('include/rootnav.php');?>
</div>
<div id="main">
<?php include('include/main.html');?>
</div>
<div id="footer">
<?php include('include/footer.php');?>
</div>
</div>
</div>
</body>
</html>
regarding the dom tool, i have the dev toolbars installed for both ie and ff. maybe i'm not using them to the full extent of their capabilities, but they've not shown any light on the situation for me as of yet.
oh, also, the css i posted up there is the layout css. i can post the style css as well, i'm just not sure what to edit out and what to keep, and it's rather long. i'll keep tinkering. thanks so much again!
CSS
#viewport {
height: auto;
width: auto;
overflow: auto;
}
#box {
width: 760px; /* IE will contain floats with this */
overflow: auto; /* compliant browsers will contain floats with this */
background: #eee;
overflow: none;
}
#header {
width: 100%;
height: 120px;
margin: 0px;
padding: 0px;
}
#staticnav {
width: 100%;
height: 34px;
padding: 2px;
}
#navcol {
float: left;
width: 130px;
background: #dad;
color: #fff;
}
#updates {
display: block;
width: 100%;
height: auto;
margin: 0px;
padding: 0px;
border: solid 1px #000;
}
#main {
height: auto;
width: 600px;
float: right;
/* no margin should be required if floated right instead */
background: #008;
color: #fff;
padding-top: 11px;
}
#footer {
clear: both;
height: auto;
width: 100%;
}
p {
margin: 0.5em 0; /* IE needs explicit margins inside floated elements */
}
HTML
<div align="center" id="viewport">
<div align="left" id="box">
<div id="header">
<p>hi! i'm the header!</p>
</div>
<div id="staticnav">
<p>and i'm the static nav!</p>
</div>
<div id="recupd">
<p>in real life, you wouldn't really be able to see me ...</p>
</div>
<div id="navcol">
<p>nav<br>nav<br>nav<br>nav</p>
</div>
<div id="main">
<p>connnnnnnnnnnnnntent.</p>
</div>
<div id="footer">
<p>and the footer.</p>
</div>
</div>
</div>
thanks to suzyuk for the code off of which i built this example :)
#box {
width: 760px; /* IE will contain floats with this */
overflow: auto; /* compliant browsers will contain floats with this */
background: #eee;
overflow: none;
}
change to:
#box {
width: 760px; /* IE will contain floats with this */
overflow: hidden; /* compliant browsers will contain floats with this */
background: #eee;
}
that should fix the scrollbar, and apart from that I would remove
align = "center" and align="left" from the HTML as unnecessary / deprecated attributes <div align="center" id="viewport">
<div align="left" id="box">
change to:
<div id="viewport">
<div id="box"> and then you can correct the centering via CSS like so..
body {
text-align: center;
}
#box {
width: 760px; /* IE will contain floats with this */
margin: 0 auto;
overflow: hidden; /* compliant browsers will contain floats with this */
background: #eee;
text-align: left;
}
#viewport is redundant in your code as it stands (you can remove all the rules from it as they are defaults anyway..) but you might want to leave it [the div] there for an extra styling hook in the future.. Suzy
if you'd like me to post the final version of the css / html, i'd be more than happy to, just as a learning guide. it is rather lengthy, however, even when edited, so be warned. i'll leave that up to our helpful moderator[s] :)
thanks again! you've saved my job ;) haha