2012-09-17 84 views
1

我是html5的初學者。當我嘗試調用html5 shiv時,頁面不會在ie8中呈現。只有背景加載。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; } 

請幫幫忙!

回答

2
  1. 您不必創建所有與document.createElement元素 - shiv爲你做。
  2. 在您的CSS中,您爲IE8製作了所有新元素inline,但是它們在良好的瀏覽器中自然會阻止。嘗試使它們一致並使用Normalize CSS中的規則,例如:
/* 
    * 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; 
    } 
相關問題