简体   繁体   English

IE8高度100%Bug

[英]IE8 Height 100% Bug

Has anyone heard of a bug that occurs with IE8 when applying height as a percentage to the html and body using CSS? 有没有人听说过使用CSS将高度作为html和body的百分比应用时IE8会出现的错误? I'm seeing a white background when a tile pattern should be applied. 我应该在应用瓷砖图案时看到白色背景。

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background-color: #666;
    background-image: url('../images/body/bg_pattern.gif');
}

IE8 interprets the height element closer to the standards than IE7 did. IE8将高度元素解释为比IE7更接近标准。 The statement 该声明

`Height: 100% `身高:100%

Is pretty much ignored. 几乎被忽略了。 Percentage heights are based upon the height of their parent element. 百分比高度基于其父元素的高度。 If the parent element doesn't have an explicit height, the percentage is ignored and set to Auto. 如果父元素没有显式高度,则忽略百分比并将其设置为“自动”。 You can see more about this on w3.org . 您可以在w3.org上看到更多相关信息。

If the page you are displaying is empty, body will have a height of 0 and you will see the default background. 如果您显示的页面为空,则正文的高度为0,您将看到默认背景。

To prevent the generated height:0 when you're floating the child elements, set 要防止生成的height:0当您浮动子元素时,请设置

overflow:hidden;
position: relative;

on the parent. 在父母身上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM