bootstrap IE8 兼容性處理
<!DOCTYPE html><html lang="zh-CN"> <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="external nofollow" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" rel="external nofollow" /> <!--[if lt IE 9]> <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <div class="row"> <div class="col-sm-6" style="border: 1px solid red;"> 左側 </div> <div class="col-sm-6" style="border: 1px solid green;"> 右側 </div> </div> </div> </body></html>
針對 IE8 仍然需要額外引入 Respond.js 文件以支持媒體查詢(media query)。
1、http協(xié)議下效果(如:http://192.168.12.40:8020/bootstrap/index.html):

2、file文件協(xié)議IE8下效果(如:C:/Users/dell/Documents/HBuilderProject/bootstrap/index.html)

如上圖所示,已經(jīng)不支持柵格布局。
主要存在的問題是:
Respond.js 與 file:// 協(xié)議
由于瀏覽器的安全機制,Respond.js 不能在通過 file:// 協(xié)議(打開本地HTML文件所用的協(xié)議)訪問的頁面上發(fā)揮正常的功能。如果需要測試 IE8 下面的響應式特性,務必通過 http 協(xié)議訪問頁面(例如搭建 apache、nginx 等)。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答