?
Solved

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

Posted on 2007-11-15
7
Medium Priority
?
478 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses
Course of the Month9 days, 10 hours left to enroll

762 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