使用bootstrap IE8相容性處理的方法

來源:互聯網
上載者:User
<!DOCTYPE html><html>    <head>        <meta charset="utf-8">        <meta http-equiv="X-UA-Compatible" content="IE=edge">        <meta name="viewport" content="width=device-width, initial-scale=1">        <title>Bootstrap IE8相容性</title>        <link href="css/bootstrap.min.css" rel="stylesheet">        <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css"/>                <!--[if lt IE 9]>              <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>              <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>        <![endif]-->            </head>    <body>        <div>            <div>                <div style="border: 1px solid red;">                    左側                </div>                <div style="border: 1px solid green;">                    右側                </div>            </div>        </div>    </body></html>

針對 IE8 仍然需要額外引入 Respond.js 檔案以支援媒體查詢(media query)。

1、http協議下效果(如:http://192.168.12.40:8020/bootstrap/index.html):

2、file檔案協議IE8下效果(如:C:\Users\dell\Documents\HBuilderProject\bootstrap\index.html)

如所示,已經不支援柵格布局。

主要存在的問題是:

Respond.js 與 file:// 協議

由於瀏覽器的安全機制,Respond.js 不能在通過 file:// 協議(開啟本地HTML檔案所用的協議)訪問的頁面上發揮正常的功能。如果需要測試 IE8 下面的響應式特性,務必通過 http 協議訪問頁面(例如搭建 apache、nginx 等)。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.