背景:颜色在IE8中不起作用 [英] Background: color does not work in IE8
问题描述
body {
background: gray;
font-family: sans-serif;
width: 960px;
margin: auto;
}
header {
background: green;
border: 10px solid black;
}
nav {
margin-top:10px;
background: #62D99C;
border-radius: 10px;
padding: 10px;
}
标题和导航背景在IE8中不起作用.它确实可以在Chrome和FF中使用.我应该怎么办?谢谢!
Header and nav background does not work in IE8. It does work in Chrome and FF. What should I do? Thanks!
推荐答案
您应将 display:block
应用于标题和导航元素:
You should apply display:block
to the header and nav elements:
header {
display: block;
background: green;
border: 10px solid black;
}
nav {
display: block;
margin-top:10px;
background: #62D99C;
border-radius: 10px;
padding: 10px;
}
似乎您还需要包含以下js:
It seems you also need to include the following js:
<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
</script>
<![endif]-->
其原因可在此处找到:
http://tatiyants.com/how-to-get-ie8-to-support-html5-标签和网络字体/
简单地说,IE8默认情况下不支持HTML5元素,但是通过使此javascript执行(仅适用于IE8或更低版本),它开始识别这些元素.大多数开发人员使用某种形式的 html5垫片
来解决此问题.
Put simply, IE8 doesn't support HTML5 elements by default, but by having this javascript execute (only for IE8 or less) it starts to recognise those elements. Most developers use some form of html5 shim
to fix this.
http://code.google.com/p/html5shim/
这篇关于背景:颜色在IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!