如何让 HTML5 标记元素在 IE 中良好显示

发布于 2024-11-27 12:00:32 字数 447 浏览 0 评论 0原文

等 HTML5 标记元素良好显示的最佳方法是什么在IE中?

通常,当我将 CSS 应用于 HTML5 元素时,样式不会发生。但我在其他网站上看到过它,例如 colourfreak.com,并且需要一些帮助。

我认为这与选择器不接受新标签名称有关。所以这样的事情是行不通的:

nav a {
    text-decoration: none;
}

详细的解释或一篇不错的文章会很有帮助。谢谢!

What is the best way to get HTML5 markup elements like <header>, <section>, and <footer> to display well in IE?

Usually, when I apply CSS to the HTML5 elements, the styling doesn't take place. But I have seen it done on other sites, like colourfreak.com, and would like some help.

I think it has something to do with the selectors not accepting new tag names. So something like this wouldn't work:

nav a {
    text-decoration: none;
}

A detailed explanation or nice article would be helpful. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南街女流氓 2024-12-04 12:00:32

对于 IE,我们必须使用 JS 创建新的 HTML5 元素。创建新文件,将其命名为 html5.js 并将此脚本包含在您的 区域中。一切都会好起来的。

document.createElement('article');
document.createElement('aside');
document.createElement('details');
document.createElement('figcaption');
document.createElement('figure');
document.createElement('footer');
document.createElement('header');
document.createElement('hgroup');
document.createElement('main');
document.createElement('menu');
document.createElement('nav');
document.createElement('section');
document.createElement('summary');

这仅对于 IE 是必需的,因此您可以使用条件注释:

<!--[if IE]><script src="js/html5.js"></script><![endif]-->

由于这些元素显示为内联元素,您可能需要在 CSS 文件中添加此规则:

article, aside, details, figcaption, figure, footer,
header, hgroup, main, menu, nav, section, summary { display: block; }

For IE we have to create new HTML5 elements with JS. Create new file, name it for example html5.js and include this script in your <head> area. All will be fine.

document.createElement('article');
document.createElement('aside');
document.createElement('details');
document.createElement('figcaption');
document.createElement('figure');
document.createElement('footer');
document.createElement('header');
document.createElement('hgroup');
document.createElement('main');
document.createElement('menu');
document.createElement('nav');
document.createElement('section');
document.createElement('summary');

This is required only for IE, so you can use conditional comments:

<!--[if IE]><script src="js/html5.js"></script><![endif]-->

Because of these elements are displayed as inline elements, you'll probably want to add this rule In your CSS file:

article, aside, details, figcaption, figure, footer,
header, hgroup, main, menu, nav, section, summary { display: block; }
睫毛溺水了 2024-12-04 12:00:32

您可以使用 HTML5 Shiv...

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

您也可以使用 HTML5 样板...(包括 HTML 5 shiv)

http:// html5boilerplate.com/

You can use the HTML5 Shiv...

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

Also you could use the HTML5 boilerplate... (Includes the HTML 5 shiv)

http://html5boilerplate.com/

孤星 2024-12-04 12:00:32

我非常确定 Modernizer 会解决您的问题以及 CSS3 的许多其他跨浏览器问题。

I'm pretty sure Modernizer will solve your problem and alot of other cross-browser issues with CSS3 as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文