views:

28

answers:

3

In my site, I have two divs - right and left. Both are contained within a wrapper div. Here is my code:

#wrapper{
    width:1000px;  
    height:750px;
    margin:auto;
}

#left{
    width:500px;
    height:750px;
    float:left;  
    position:relative;
}

#right{
    width:500px;
    height:750px;
    float:right;
    position:relative;
}

In Chrome, no problem.

In Firefox, no problem.

In Safari, no problem.

In Opera, no problem

In IE, the #right div is in the same location horizontally, but vertically it's below the #left div.

I've tried a few different techniques to remedy this. Setting the wrapper line height to 0, setting the right display to inline, reducing the size of the right and left divs (I thought maybe there was a margin/padding issue). I've run out of ideas now, can anybody offer any help of the issue?

In All Browsers (except IE): alt text

In IE: alt text

+1  A: 

Try using float:left for both the #right and #left divs. You could also probably take out the position: relative as well.

derekerdmann
I tried this, unfortunately the right div now appears DIRECTLY underneath the left, instead of alongside-underneath, if you know what I mean
Daniel Hanly
@Daniel Hanly - Try setting the left margin of the `#right` div to the width of the `#left` one. You might need to make the left one smaller by a few pixels, too.
derekerdmann
+1  A: 

put both left and right divs as float:left

Thomas Clayson
I tried this, unfortunately the right div now appears DIRECTLY underneath the left, instead of alongside-underneath, if you know what I mean
Daniel Hanly
check your widths/paddings/margins... is there anything that is expanding the left or right div? If so then it will get pushed underneath.
Thomas Clayson
can we have a link to a working example at all please?
Thomas Clayson
the picture on the link you gave me is (computed in firebug as) 501px wide. this might be your problem.
Thomas Clayson
try making your #right div 450px wide and see if that works how it should... this will tell you if its a width issue.
Thomas Clayson
Thanks for all your help Thomas, I've resolved the problem now and it is what you suggested, there was an image on both sides that was 501px so I changed it and it's resolved the problem (with some code hacking involved) cheers,
Daniel Hanly
+2  A: 

There's nothing wrong with the CSS you've posted. It will work in all browsers as expected (I've decreased the widths in my example).

What's happening is that you've got an element in one of your columns that's forcing the width of either #left or #right to be greater than 500px. The easiest way to fix this is to start removing elements until the float drop disappears. Then you can figure out if there's a solution for the offending element (i.e. set its width or set overflow: hidden or scroll).

Pat
Thanks, I'll scan my code for the culprit at one :) Cheers
Daniel Hanly
Found it, thanks for your help Pat
Daniel Hanly