IE8 Height 100% Bug

烈酒焚心 提交于 2020-01-02 06:45:22

问题


Has anyone heard of a bug that occurs with IE8 when applying height as a percentage to the html and body using CSS? 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');
}

回答1:


IE8 interprets the height element closer to the standards than IE7 did. The statement

`Height: 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.

If the page you are displaying is empty, body will have a height of 0 and you will see the default background.




回答2:


To prevent the generated height:0 when you're floating the child elements, set

overflow:hidden;
position: relative;

on the parent.



来源:https://stackoverflow.com/questions/4772396/ie8-height-100-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!