IE中有问题的边距和奇怪的滚动行为

时间:2014-11-11 04:03:17

标签: html css html5 css3

我试图在我目前的设计中重现我遇到的问题。首先,这里是链接: http://cssdeck.com/labs/tohtb9gx

HTML:

<head><title>test</title></head>
<html>
    <body>
        <div id="container">            
            Test what is going on?
        </div>
    </body>
</html>

和css:

body {
    margin: 0;
    background-color: black;
    font-size: 2em;
    color: white;   
}
#container {
    margin: 100px;
}

问题是margin。当存在这么大的余量时,无论内容有多少,IE总是使用滚动呈现页面。 Chrome和FireFox中的页面很好,但即使没有内容,神奇的强大的IE总是渴望神秘的卷轴。

为什么会这样?

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

以下是您的问题的解决方案。 给身体漂浮。

body {
  margin: 0;
  background-color: black;
  font-size: 2em;
  color: white;
  height: 100%;
  width: 100%;
  float: left;
}
#container {
  margin: 100px;
}
<html>

<head>
  <title>test</title>
</head>

<body>
  <div id="container">
    Test what is going on?
  </div>
</body>

</html>

相关问题