ie6 和 ie7 中的 css float 问题

标签 css internet-explorer-7 css-float internet-explorer-6

我在 IE6 和 ie7 中有一个 float 问题:

  <!DOCTYPE html>
    <html>
    <head>
    <title>lily</title>
    <style>
        div{width: 100px; height: 100px;}
        .div1{background: red; float: left;}
        .div2{background: yellow;}
    </style>
    </head>
    <body>
        <div class="div1">div1</div>
        <div class="div2">div2</div>
    </body>
</html>

为什么在IE6&&IE7和Chrome中显示不一样?以及在ie6&ie7中如何解决?

:

最佳答案

   <!DOCTYPE html>
<html>
<head>
<title>lily</title>
<style>
    div{width: 100px; height: 100px;}
    .div1{background: red; float: left;}
    .div2{background: yellow; clear:both;}
</style>
</head>
<body>
    <div class="div1">div1</div>
    <div class="div2">div2</div>
</body>

enter image description here

关于ie6 和 ie7 中的 css float 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20320458/

相关文章:

css - 有什么方法可以让 Chrome 顺利地进行 letter-spacing 的 CSS 转换?

css - 实验性 CSS 和老式浏览器

html - 如何防止我的 ul 列表断线? [duplicate3 - 仍然找不到解决方案]

html - float 文本无需扩展容器 div 宽度

当顶级元素不是 div 时,CSS 网格格式不一致

CSS li 元素在 IE7 中显示不正确

jQuery .ajax 方法在 IE7 和 IE6 中不起作用,但在 Firefox 中工作正常

css - IE7 : block inside table with percentage-margin

html - margin 如何运作?

html - CSS 和 div 定位