html - div 的宽度在 IE7 中受另一个 div 的内容影响

标签 html css internet-explorer

这是一个 HTML 页面的示例,该页面由一个页眉和一个页脚以及一个包含另一个包含一些内容的 div 的 div 组成:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    <title>Testing 123</title>
    <link rel="stylesheet" href="css/testing.css">
</head>
<body>
    <div id="main_body">
        <div id="header"></div>
        <div id="content_container">
            <div id="content">
                Some text<br>
            </div>
        </div>
       <div id="footer"></div>
    </div>
</body>
<html>

这是CSS:

* {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
border: none;
z-index: 10;
font-family: Arial;
font-size: 20px;
text-decoration: none;
text-align: left;
}
html, body {
height: 100%;
background-color: rgb(255, 255, 255);
}
#main_body {
position: relative;
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0px 20px 0px 20px;
}
#header {
position: absolute;
top: 20px;
left: 0px;
height: 50px;
width: 100%;
background-color: rgb(40, 40, 40);
}
#content_container {
padding: 80px 10px 50px 10px;
}
#content {
padding: 0px 4px 0px 4px;
position: relative;
}
#corner_top_left {
position: absolute;
width: 7px;
height: 7px;
top: 0;
left: 0;
background-color: rgb(40, 40, 40);
}
#footer {
position: absolute;
bottom: 20px;
left: 0px;
height: 20px;
width: 100%;
background-color: rgb(40, 40, 40);
}

请注意,我还没有使用 corner_top_left 样式。我希望内容有漂亮的圆 Angular 。我知道有很多不同的方法可以实现这一目标。我选择有一个相对位置的容器,您可以在其中设置绝对定位的小 Angular div。这种方法对我来说效果很好,但在这个特定示例中的 IE7 中有一个我无法解释的非常奇怪的效果。

观察将 content_top_left div 添加到示例时会发生什么,如下所示:

....
<div id="header"></div>
<div id="content_container">
    <div id="content">
        <div id="corner_top_left"></div>
        Lots of text<br>
    </div>
</div>
<div id="footer"></div>
....

出于某种原因,现在调整了页脚的宽度(变短了)。我不知道为什么在 IE7 中会发生这种情况(在 FF 中工作正常)。页脚不应受内容影响。有谁知道这里发生了什么以及如何解决这个问题?

编辑:我稍微更改了示例,使其更类似于我当前的网站。

最佳答案

尝试将#content_container 的内边距从 padding: 0 10px 0 10px; 设置为 padding:0。它解决了 IE7 中的问题,但我在 IEtester 中运行它。

关于html - div 的宽度在 IE7 中受另一个 div 的内容影响,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2162280/

相关文章:

javascript - Canvas 绘图工具

javascript - 清除 input[type=file] 值时,jQuery onChange 不会触发

html - 100% 高度非 Canvas 粉底 5

html - 应用网页上使用的字体类型

html - IE 7 及以下版本中的 float 导航?

javascript - IE 9.0 中未存储第三方 cookie

html - 如何在CSS中增加右侧div中的左侧div大小

带有 CSS3 响应式设计的 jQuery Mobile

html - Bootstrap 列重新排序大小问题

html - 没有 IE 和 Firefox 背景