无法在 IE 中设置 HTML5 元素的样式(尽管有 shiv 和 display:block)
我似乎无法弄清楚缺少什么。所有受影响的元素都有 display:block
header
元素的示例样式:
header
{
width: 923px;
height: 55px;
background: #395168;
margin-top: 25px;
}
I can't seem to work out what's missing. All the affected elements have display:block
Example style for the header
element:
header
{
width: 923px;
height: 55px;
background: #395168;
margin-top: 25px;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
IE 6-8 不知道 header 标记,因此无法对其应用样式。要使 IE 理解此标记,请在 head 部分添加以下脚本。
这可以解决你的问题。
IE 6-8 doesn't know about the header tag, so that the styles can't be applied to it. To make IE to understand this tag, add the below script in your head section.
This would solve your problem.
解决了问题。我所做的是将脚本链接放在样式表链接下,突然 IE 6-8 应用了我的样式。
非常感谢您尝试帮助我:)
Solved the issue. What i did was that i put the script-link under the stylesheet link and suddenly IE 6-8 applied my styles.
Thank you so much for trying to help me :)
也许只是尝试给它上课?
Maybe just try giving it a class?
IE 目前不允许将样式应用于这些元素。我解决这个问题的方法是将它们包装在另一个 div 中:
这显然不是很好,但它击败了任何依赖 JS 的解决方案,因为它不会在禁用 JS 的情况下奇怪地显示。
IE doesn't currently allow styling to be applied to these elements. The way I solve it is by wrapping them in another div:
This isn't great obviously, but it beats any solution that relies on JS as it won't display strangely with JS disabled.
今天我自己也遇到了这个问题,升级到最新的 html5shiv 代码(现已移至 Github:https://github.com/aFarkas /html5shiv),将样式表移到脚本链接上方,所有元素都设置了 display:block 但仍然没有成功设置它们的样式...
我意识到我的标记中没有 doctype 声明 - 添加:
解决了问题,所有款式现在正确应用 - 如此完整的解决方案:
Had this problem myself today, upgraded to latest html5shiv code (now moved to Github here: https://github.com/aFarkas/html5shiv), moved the stylesheet above the script link, all elements had display:block set but still no luck styling them...
The I realised I had no doctype declaration in my markup - adding:
solved the problem, all styles now applying correctly - so complete solution: