views:

169

answers:

4

Hi geeks,

Here is my code,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>[your title]</title>
    <style type="text/css">
    .a, .b, .c
    {
        float: left;
    }
    .b
    {
        clear: left;
    }
    </style>
</head>
<body>
<div class="a">1</div>
<div class="b">2</div>
<div class="c">3</div>
</body>
</html>

In IE8, firefox, chrome, safari, opera, the output will be:

1
23

However in IE7:

13
2

I have search for solutions two days already... anyone can help?

Cheers, bGiraffe

+1  A: 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>[your title]</title>
    <style type="text/css">
    .a, .b, .c
    {
        float: left;
    }
    .b
    {
        clear: left;
    }
    </style>
</head>
<body>
<div class="a">1</div>
<div style="clear: left;"></div>
<div class="b">2</div>
<div class="c">3</div>
</body>

Dustin Laine
Thx for answing Durilai, but is there anyways to do it in css? I want to do it without source mark up:)
bGiraffe
A: 

this should fix it

.a, .b, .c { float: left; }
.b { clear: both; }
pixeltocode
Why would that be any different than what he has? He has no right floats, so clear: left would do it.
Dustin Laine
A: 

Or you could use the clearfix technique.

http://www.positioniseverything.net/easyclearing.html

chimerical
That is for pushing down the bottom edge of a container to wholly contain its floated children, which is a different problem altogether.
Tgr
A: 

FYI I asked the same question after reading this one and got a working solution from graphicdivine here:

http://stackoverflow.com/questions/2614566/ie7-and-ie8-float-clearing-without-adding-empty-elements

["Circular post reference error" ;)]

tk-421