Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为什么IE中的机身宽度相差负4个像素_Html_Css - Fatal编程技术网

Html 为什么IE中的机身宽度相差负4个像素

Html 为什么IE中的机身宽度相差负4个像素,html,css,Html,Css,这是我的强迫症,但我必须知道这种行为是否有解释。我有一个1280x1024视口的监视器。我有一个网站,我想集中在页面上。我还希望该网站的宽度是1280像素宽 现在,使用FF和Opera,我可以将body设置为100%,将wrapper设置为1260px(考虑滚动条),而没有水平滚动条。如果我使用IE7或IE8,我会得到一个水平滚动条 FF和Opera以1260px(假设一个17px的滚动条)计算主体宽度,而IE以1259px计算主体宽度。我在IE中测量了滚动条,它也是17px 为什么会这样 就是

这是我的强迫症,但我必须知道这种行为是否有解释。我有一个1280x1024视口的监视器。我有一个网站,我想集中在页面上。我还希望该网站的宽度是1280像素宽

现在,使用FF和Opera,我可以将body设置为100%,将wrapper设置为1260px(考虑滚动条),而没有水平滚动条。如果我使用IE7或IE8,我会得到一个水平滚动条

FF和Opera以1260px(假设一个17px的滚动条)计算主体宽度,而IE以1259px计算主体宽度。我在IE中测量了滚动条,它也是17px

为什么会这样

就是这样

@import url("reset.css"); <- Erik Meyers reset
html, body{
  width:100%;
  background:#ccc;
  font-size:100%;
  /**overflow-x:hidden;**/ <-- Works fine with overflow-x:hidden
  font-family:Arial;
}

#wrap-page{
  margin:auto;
  width:1263px;
}

#wrap-content{
  margin:0 5px;
}

<!DOCTYPE html>
<html>
  <head>
  <title></title>
  </head>
  <body>

    <div style="wrap-page">
      <div style="wrap-page">
        <div style="float:left;height:2000px;width:1263px;">The test</div>
        <div style="clear:both;"></div>
      </div>
      <div style="clear:both;"></div>
    </div>

  </body>
</html>

导入url(“reset.css”) 你正在使用重置css

body{
margin:0;
padding:0;
}

*{
margin:0;
padding:0;
}

或者您可以使用ie\9 hack

如果你的CSS看起来像这样

#myElement {
    width: 300px;
    width: 500px\9;
}
在IE 7、8和9中,结果将是
#myElement
500像素宽,而在所有其他浏览器中,
#myElement
将是300像素宽


Hi Surinder,是的,我正在使用重置。只需设置
overflow-x:hidden,诅咒IE,今天到此为止。嘿,谢尔曼先生,我同意并且已经这么做了,但这是让我非常恼火的事情之一。我只是想看看有没有什么解释;可能是我忽略了什么。@user1709311哪一个是外部分区?包装页还是包装内容?对不起,Surinder,我忘了发布html。我现在就把它扔上去。谢谢你,我已经在用重置了。谢谢这是一个很好的回答。现在就上去。谢谢你看,上面贴着呢。我刚看过你的代码。你的代码是完美的,你可以使用ie特定的css我更新了我的答案..谢谢Surinder。我以前从未见过这种黑客行为。我现在就去试试。