IE7浮动并清除相同的元素

时间:2010-03-18 05:43:46

标签: css internet-explorer css-float clear

这是我的代码,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>

在IE8中,firefox,chrome,safari,opera,输出将是:

1
23

然而在IE7中:

13
2

我已经两天寻找解决方案......任何人都可以提供帮助吗?

干杯, bGiraffe

3 个答案:

答案 0 :(得分:1)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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>

答案 1 :(得分:0)

这应该解决它

.a, .b, .c { float: left; }
.b { clear: both; }

答案 2 :(得分:0)

或者您可以使用clearfix技术。

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