使用bootstrap IE8兼容性处理的方法

css教程评论400 views阅读模式
<!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):

使用bootstrap IE8兼容性处理的方法

2、file文件协议IE8下效果(如:C:\Users\dell\Documents\HBuilderProject\bootstrap\index.html)

使用bootstrap IE8兼容性处理的方法

如上图所示,已经不支持栅格布局。

主要存在的问题是:

Respond.js 与 file:// 协议

由于浏览器的安全机制,Respond.js 不能在通过 file:// 协议(打开本地HTML文件所用的协议)访问的页面上发挥正常的功能。如果需要测试 IE8 下面的响应式特性,务必通过 http 协议访问页面(例如搭建 apache、nginx 等)。

以上就是使用bootstrap IE8兼容性处理的方法的详细内容,更多请关注css教程其它相关文章!

企鹅博客
  • 本文由 发表于 2019年9月17日 19:50:37
  • 转载请务必保留本文链接:https://www.qieseo.com/357920.html

发表评论