HTML5 shiv在ie8中断页面

时间:2012-09-17 16:35:31

标签: html5 internet-explorer-8

我是html5的初学者。当我尝试调用html5 shiv时,页面不会在ie8中呈现。只加载背景。

我正在添加以下内容

<header>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">     </script><![endif]-->   
<script>
  document.createElement('header');
  document.createElement('nav');
  document.createElement('hgroup');
  document.createElement('section');
  document.createElement('article');
  document.createElement('aside');
  document.createElement('footer');
   </script>

的CSS:

article, aside, details, figcaption, figure, footer, header, hgroup, nav, section {     display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }

请帮忙!

1 个答案:

答案 0 :(得分:2)

  1. 您不必使用document.createElement创建所有元素 - shiv会为您完成。
  2. 在你的CSS中,你为IE8制作了所有新元素inline,但它们在好的浏览器中自然会被阻止。尝试使它们保持一致,并使用Normalize CSS中的规则,例如:
  3.     /*
        * Corrects `block` display not defined in IE 8/9.
        */
    
        article,
        aside,
        details,
        figcaption,
        figure,
        footer,
        header,
        hgroup,
        nav,
        section,
        summary {
            display: block;
        }
    
        /*
        * Corrects `inline-block` display not defined in IE 8/9.
        */
    
        audio,
        canvas,
        video {
            display: inline-block;
        }
    
        /*
        * Prevents modern browsers from displaying `audio` without controls.
        * Remove excess height in iOS 5 devices.
        */
    
        audio:not([controls]) {
            display: none;
            height: 0;
        }
    
相关问题