internet-explorer - CSS simple float left 在IE兼容模式下的问题

标签 internet-explorer css ie-compatibility-mode

我试图并排放置两个框(一个 200 像素的左侧菜单,旁边是 100% 剩余宽度的主要内容区域)。

它在所有浏览器中都可以正常工作,但是我们的很多客户都在使用 IE6(不幸的是我们对此无能为力),所以这必须支持 IE 兼容模式。不幸的是,这个简单的 CSS 不起作用!有人可以帮助我而不需要回到 table 上吗?

相关 CSS:

.clear {
    clear:both;
}

/* Left menu */
.leftMenu{
    width: 200px;
    border:1px solid green;
    height:100px;
    float:left;
}

/* Main Content area */
.mainBox{
    width:100%;
    border:1px solid red;
}
.mainWrapper{
}




<!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><title>



</title><link rel="stylesheet" type="text/css" href="css/default.css" /></head>



<body>

    <form name="form1" method="post" action="default.aspx" id="form1">

<div>

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTIwNjAyODU4M2Rk5phxJ78Kc9Kf0nXvcJ7j7tQJPxw=" />

</div>

    <div class="mainWrapper">

        <div class="leftMenu">

        left

        </div>

        <div class="mainBox">

        main

        </div>

        <div class="clear"></div>

    </div>



    </form>

</body>

</html>

最佳答案

没有 IE6,所以无法测试,但无论如何。尝试从 .mainBox 中删除 width: 100% 并删除所有边框,而是使用背景色进行测试。我以这种方式让它在 IE7 标准中工作。

.mainBox 是一个没有任何 float 的 DIV,因此它隐含 100% 宽。此外,边框添加到宽度,因此可能会在测试时导致意外行为。

关于internet-explorer - CSS simple float left 在IE兼容模式下的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4792859/

相关文章:

jQuery fadeIn 在 IE7 中留下未消除锯齿的文本

c# - 如何以另一个用户(la/netonly)身份启动 Internet Explorer 进程?

html - 调整相邻 header 标签的边距

html - btn-block 按钮的 Bootstrap 设置高度

internet-explorer - IE11 开发工具中的 IE7/8/9/10 模拟器在哪里?

internet-explorer - 如何防止IE9在兼容模式下渲染内网站点

javascript - 是否可以覆盖 http-equiv ="X-UA-Compatible"内容 ="IE=7"

Jquery 自动完成滚动条未出现在 IE 中

Javascript 到 CSV 函数与 IE 或 Firefox 不兼容

css - 使用 Css Sprite 和背景位置