• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

Float and clear problem in IE, div is jumping up to the top

I have a problem with divs floating to the top in IE (tried in IE 6 and IE 7 with the same result).  

This is how it should look:  On the right side of the page we first have one div (brown in the example), under this another (green).  Under the green we should have two divs that together are just as wide as the green one: One red at the right, and left to the red; one in blue.  The red and the blue are not of the same length.  Around all this there should be text wrapping around it.  Here is a picture of how it should look:
http://iris.idg.no/ulf/div/skisse.jpg

Firefox and Opera renders this just fine with the blue and the red next to each other lying under the green.  But in IE, the blue jumps to the top next to the brown.

I have been able to get the red and the blue boxes next to each other in IE (with various versions of clear both in a div above them), but then the text wrapping around all the divs fails, and the text body starts at the same height as the red and blue.

Any idea how this design could be made working in IE?
<style>
 
.ad 
{
    background-color:#996600;
    float: right;
    width: 300px;
    height: 200px;
}
 
.article_image
{
    float: right;
    margin: 0 0 0px 10px;
    clear: right;
    background-color:#339966;
    width: 200px;
    height: 150px;
}
 
#redBox
{
  width:100px; 
  height:300px;
  float: right;
  clear:right;
}
 
#blueBox
{
  width:100px; 
  height:150px;
  float:right;
 
}
 
.text
{
    float: left;
    margin: 0 0 10px 10px;
    clear: left;
}
 
#tittel
{
    margin: 0 0 10px 0px;
}
 
#ingress
{
    margin: 0 0 10px 0px;
}
 
 
</style>
 
</head>
 
<body>
 
 
<div id="Text" class="text">
    <div id="tittel">
    <b>This is a long and fine title.   Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </b> 
    </div>
 
  <div id="ingress">
    This is a lead text.  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, 	vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
  </div>
    
    <div class="ad">
        Advertisement
    </div>
    
    <div class="article_image">
        Article image
    </div>
        <div id="redBox" style="background-color:#CC0000">
	    Red box
	    Lorem Ipsum
        </div>
        
        <div id="blueBox" style="background-color:#0066FF">
	    Blue box
	    Lorem Ipsum
        </div> 
 
    
 
 
    <div id="body">
    This is the article body. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
  </div>
    
 
</div>

Open in new window

0
ulf_hh
Asked:
ulf_hh
  • 4
1 Solution
 
Eternal_StudentCommented:
Do this:


      <div style="float:right; width:200px; height:300px; clear:right">      
            <div id="redBox" style="background-color:#CC0000">
                        Red box
                        Lorem Ipsum
            </div>  
            
            <div id="blueBox" style="background-color:#0066FF">
                        Blue box
                        Lorem Ipsum
            </div>
 </div>
0
 
Eternal_StudentCommented:
So I just nested the two divs in a div that does exactly what the other divs do ... float:right and clear:right
0
 
Eternal_StudentCommented:
The only problem is .. the text will not wrap under the blue div as the height of its' parent is that of the red div. Not sure if that is a major issue but I can't think of any other way you could do it?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ulf_hhAuthor Commented:
I've already thought about this, but I'm afraid this will be a major issue (as this will not fit with objects under these boxes that are not shown in this example).  The text must flow around and leave no "blank boxes" like this.
0
 
Eternal_StudentCommented:
Then I am stumped!
0
 
oceanbeachCommented:
Hello ulf_hh,

This question caught my attention & I could not stop thinking about the behavior of IE6.   I tried a few things &  this seems to work in IE6, FF, Opera & Safari.  Although, this will only work if both the height of the blue div is known & the width of the red div is known.

In the HTML, switch the places of the red & blue divs, so that the blue div appears first.  Also, add a few styles your the css...

I hope this helps!

oceanbeach
HTML:
  <div id="blueBox" style="background-color:#0066FF"> Blue box Lorem Ipsum </div>
  <div id="redBox" style="background-color:#CC0000"> Red box Lorem Ipsum </div>
 
CSS:
#redBox
{
  width:100px; 
  height:300px;
  float: right;
  clear:right;
  margin-top: -150px;
}
#blueBox
{
  width:100px; 
  height:150px;
  float:right;
  clear:right;
  margin-right: 100px;
  display: inline;
}

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now