zoukankan      html  css  js  c++  java
  • 兼容低于IE9不支持html5标签的元素的方法

    方法一:

    <!--[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]-->

    如果是IE9以下的IE浏览器将创建HTML5标签, 这样非IE浏览器就会忽视这段代码,也就不会有无谓的http请求了。

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

    <!--[if lt IE9]> 
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    但是不管使用以上哪种方法,都要初始化新标签的CSS.因为HTML5在默认情况下表现为内联元素,对这些元素进行布局我们需要利用CSS手工把它们转为块状元素方便布局
    article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}
  • 相关阅读:
    UVA232-纵横字谜的答案
    【SpringBoot】Re 02 Import与自定义装配实现
    【SpringBoot】Re 01 补充学习
    【ECharts】04 数据交互
    【ECharts】03 样式
    【ECharts】02 饼图
    【ECharts】01 快速上手
    【Mycat】01 概述
    【Git】05 分支管理
    【Git】04 文件删除
  • 原文地址:https://www.cnblogs.com/family-626-77/p/5765155.html
Copyright © 2011-2022 走看看