Solved

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

Posted on 2007-11-15
7
472 Views
Last Modified: 2013-12-08
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
Comment
Question by:ulf_hh
  • 4
7 Comments
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20287950
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
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20287955
So I just nested the two divs in a div that does exactly what the other divs do ... float:right and clear:right
0
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20287966
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ulf_hh
ID: 20287992
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
 
LVL 18

Expert Comment

by:Eternal_Student
ID: 20288108
Then I am stumped!
0
 
LVL 12

Accepted Solution

by:
oceanbeach earned 500 total points
ID: 20302746
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Several part series to implement Internet Explorer 11 Enterprise Mode
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now