【问题标题】:Div with 100% height has an small margin on bottom高度为 100% 的 Div 底部的边距很小
【发布时间】:2015-07-09 01:51:57
【问题描述】:

我有一个在 IE8 上难以解决的问题。我需要一个 100% 高度的 div,但我尝试过的所有方法都不能解决问题。

你可以在这里看到问题:http://gyazo.com/71ffde560df4d3f87c0fb55a92ef8313

或在此处复制:http://maahes.ninja/ie/ie.html

问题是页面底部的白色边距很小,而且这只发生在 ie8 上(在 ie9 上没问题)。我能够通过删除 doctype 来解决它,但它可以解决问题,但会破坏所有应用程序。

CSS:

html,body,div,span,applet,object,iframe,
h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,
del,dfn,em,img,ins,kbd,q,s,samp,
small,strike,strong,sub,sup,tt,var,
b,u,i,center,
dl,dt,dd,ol,ul,li,
fieldset,form,label,legend,
table,caption,tbody,tfoot,thead,tr,th,td,
article,aside,canvas,details,figcaption,figure,
footer,header,hgroup,menu,nav,section,summary,
time,mark,audio,video{
    margin:0;
    padding:0;
    border:0;
    outline:0;
    font-size:100%;
    font:inherit;
    vertical-align:baseline;
}

html {
    height: 100%;
}

body { 
    height: 100%;
}

div {
    height: 100%;
    min-height: 100%;
    background:#9699FF;
    color:#fff;
}

很抱歉没有添加更多图片/链接,但我对此毫无名气。

【问题讨论】:

标签: html css internet-explorer-8


【解决方案1】:

您分享的屏幕截图没有白边。你看到的是一个带有浮雕的 Windows GUI-Element——IE8s 浏览器窗口的边框。

您可以尝试通过为<html> 标签添加红色背景来验证这一点。

html {
  background: red;
}

如果您的 div 上有任何类似边距的效果,那么您应该会看到红色背景。

我在我的 IE8/WinXP 虚拟机上测试了您的链接,并且没有多余的余量。 (见:Screenshot

我放大了屏幕截图的左下角 (click here),以便更清楚地看到内部窗口边框。

【讨论】:

  • 你是对的!非常感谢 :) 将其标记为正确答案
猜你喜欢
  • 2014-12-20
  • 2013-04-04
  • 2011-05-03
  • 2018-05-30
  • 2012-04-08
  • 2011-08-03
  • 1970-01-01
  • 2013-04-13
  • 2012-07-09
相关资源
最近更新 更多