完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法

来源:互联网 发布:时时彩计算软件 编辑:程序博客网 时间:2024/04/28 09:51

方式一:Coding JavaScript

<!--[if lt IE9]> <script>    (function() {     if (!      /*@cc_on!@*/     0) return;     var e = "abbr, article, aside, audio, canvas, datalist, details, dialog, eventsource, figure, footer, header, hgroup, mark, menu, meter, nav, output, progress, section, time, video".split(', ');     var i= e.length;     while (i--){         document.createElement(e[i])     } })() </script><![endif]-->

第二种方法:使用Google的html5shiv包(推荐)

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

但是不管使用以上哪种方法,都要初始化新标签的CSS.因为HTML5在默认情况下表现为内联元素,对这些元素进行布局我们需要利用CSS手工把它们转为块状元素方便布局
/*html5*/article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}

原文转自:http://www.cnblogs.com/Capricornus/archive/2013/03/26/2982122.html

0 0