css - Internet Explorer 8 背靠背 div CSS 问题

标签 css internet-explorer html

以下布局在每个浏览器(Firefox、Chrome、Opera)中都能正常工作,Internet Explorer 8 除外:

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <link href="style.css" rel="stylesheet" type="text/css"/>
    <head>
    <body>
        <div id="divMain" class="CMain">
            <div id="divL" class="CLeft">
            </div>
            <div id="divR" class="CRight">
            </div>
        </div>
    </body>
</html>

CSS:

.CMain {
    position: absolute;
    overflow: hidden;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 75%;
    min-width: 500px;
    min-height: 400px;
    max-height: 550px;
    background-color: cyan;
    border: 1px solid #000000;
    margin: 0 auto;
}

.CLeft {
    position: absolute;
    overflow: visible;
    top: 0px;
    right: 50%;
    width: 49%;
    height: 100%;
    min-width: 200px;
    min-height: 450px;
    max-width: 450px;
    max-height: 550px;
    background-color: yellow;
    border: 1px solid #000000;
    margin: 0 auto;
    padding: 0px;
}

.CRight{
    position: absolute;
    overflow: visible;
    top: 0px;
    left: 50%;
    width: 49%;
    height: 100%;
    min-width: 200px;
    min-height: 450px;
    max-width: 450px;
    max-height: 550px;
    background-color: blue;
    border: 1px solid #000000;
    margin: 0 auto;
    padding: 0px;
}

这两个内部 div 应该背靠背位于主 div 的中心,而且它们显然存在于除 IE8 之外的所有浏览器中。在 IE8 中,左边的 div 到左边,而不是在中间。

我做错了什么吗? (请不要建议删除最小/最大宽度/高度限制,它们是必需的)。任何建议将不胜感激。

这是一个关于此设置的 fiddle :http://jsfiddle.net/fNtJU/

imageshack 截图链接 ie8: http://img831.imageshack.us/img831/3838/ie8g.jpg

最佳答案

您是否尝试过在主容器上设置宽度?例如,宽度:90%;并丢失 left:20px;/right:20px;。我不认为当父级没有明确指定宽度时子容器可以计算位置,即使使用最大宽度也是如此。不过,我目前无法在 ie8 上进行测试。

关于css - Internet Explorer 8 背靠背 div CSS 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12414502/

相关文章:

jquery - IE8 和 IE9 的 Fancybox 样式问题

html - 我可以只为 div 的背景图像设置不透明度吗?

html - IE7 的 CSS 问题

JavaScript cssText 在 Firefox 和 Opera 浏览器中无法正常工作

javascript - 为什么 $(window).load() 在 IE10 中不起作用

performance - 为什么在 Internet Explorer 中随着内存使用量的增加页面会变慢

android - 关于使用 jQuery Mobile 和 html 开发 android 应用程序

javascript - 根据复选框显示/隐藏文本框

javascript - 如何获得文本尺寸?

css - IE 中的 SVG 背景 repeat-x