Css 如何使用IE7+;使我的网页看起来正常;?

Css 如何使用IE7+;使我的网页看起来正常;?,css,html,internet-explorer,Css,Html,Internet Explorer,我最近重构了我的网站以使用HTML5。除了IE7和IE8之外,它在大多数浏览器中都可以正常工作 它看起来像是由于使用了,和标签,而这些标签显然被IE7忽略了。我的css为这些类定义了特定的标记格式化子类 header { color: #fff; background: url("background1.jpg"); padding: 10px 40px 20px 40px; margin-bottom: 20px; } header a { color: #fff; tex

我最近重构了我的网站以使用HTML5。除了IE7和IE8之外,它在大多数浏览器中都可以正常工作

它看起来像是由于使用了,和标签,而这些标签显然被IE7忽略了。我的css为这些类定义了特定的标记格式化子类

header { color: #fff;  background: url("background1.jpg"); 
        padding: 10px 40px 20px 40px; margin-bottom: 20px; }
header a { color: #fff; text-decoration: none; outline: none; }
header a:hover { color: #fff; text-decoration: underline; }
header h1 { color: #FFFFFF; font-weight: bold; font-size: 30px; 
          padding-bottom: 20px; padding-top: 0px; }
header h2 { color: #FFFFFF; font-weight: bold; font-size: 16px; padding-bottom: 10px; }
header hr { margin: 10px 10px 0px 0px; }
header .copyright { font-style: italic; font-weight: bold; 
    padding-left: 30px; padding-right: 0px; }

section { padding: 5px 40px 5px 40px; line-height: normal; }

article .main { font-weight: bold; font-size: 20px; line-height: normal; }
我跳过了其他不会引起问题的样式定义


我怎样才能避开这个问题?我必须放弃HTML5标签吗

您可以在头部部分使用此脚本:

<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->


大多数html5在IE中对我有用吗:-)

问题是浏览器对他们根本不识别的标签有特殊处理;诸如应用样式和能够包含子项之类的基本功能将不起作用

Html SHIV,比如RTB链接的Html SHIV,将通过javascript注入对这些html5标记的基本识别,以便浏览器将它们识别为有效标记,这意味着您可以对它们进行样式设置

诸如Modernizer之类的库还包括html5 shiv(尽管在其他方面,Modernizer不支持html5功能)
请注意,shiv通常只允许基本标记识别,因此您可以设置元素的样式。它无法启用功能。

您可以尝试在javascript中创建元素,IE将呈现它

document.createElement('header');
document.createElement('section');
document.createElement('article');

我必须承认,HTML和浏览器支持这种向后兼容的可能性令人印象深刻。我知道这很神奇,不是吗。如果我们不再在使用IE时遇到这么多麻烦,那就更好了。这对我帮助很大,真的:)