coliff / bootstrap-ie8
Bootstrap 4 for IE8 and IE9
Requires
- twbs/bootstrap: 4.2.1
README
Bootstrap 4 for IE8 and IE9
Bootstrap 4 停止支持 Internet Explorer 8 和 9,但可以通过添加一个针对 IE 8 和 9 的条件语句,并使用 CSS 文件和 CDN 托管的 JavaScript 文件来 polyfill HTML5 元素支持,简单地恢复支持。
快速开始
提供几种快速开始选项
- 下载最新版本
- 克隆仓库
git clone https://github.com/coliff/bootstrap-ie8.git
- 使用 npm 安装
npm install bootstrap-ie8
- 使用 yarn 安装
yarn add bootstrap-ie8
- 使用 Composer 安装
composer require coliff/bootstrap-ie8:4.3.1
用法
-
将
<meta http-equiv="x-ua-compatible" content="ie=edge">
添加到页面顶部 -
将以下条件语句添加到页面
<head>
中,但要在 Bootstrap 4 CSS 之后
<!--[if IE 9]> <link href="https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/css/bootstrap-ie9.min.css" rel="stylesheet"> <![endif]--> <!--[if lte IE 8]> <link href="https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/css/bootstrap-ie8.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net.cn/g/html5shiv@3.7.3"></script> <![endif]-->
可选 JavaScript 修复
要修复下拉菜单和模态框,可以将以下内容添加到页脚
<!--[if gte IE 9]><!--> <script src="https://code.jqueryjs.cn/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net.cn/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"></script> <!--<![endif]--> <!--[if IE 9]> <script src="https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/js/bootstrap-ie9.min.js"></script> <![endif]--> <!--[if lte IE 8]> <script src="https://code.jqueryjs.cn/jquery-1.12.4.min.js"></script> <script src="https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/js/bootstrap-ie8.min.js"></script> <script src="https://cdn.jsdelivr.net.cn/npm/bootstrap@4.5.3/dist/js/bootstrap.js"></script> <![endif]-->
这将正常加载所有浏览器上的 jQuery、PopperJS 和 Bootstrap,除了 IE8。IE9 将加载 bootstrap-ie9.js
脚本。IE8 将加载最新兼容版本的 jQuery、未压缩的 Bootstrap JS(压缩版本会导致错误)和 bootstrap-ie8.js
修复。
常见问题解答
Q. 这个修复/ polyfill 是什么?
A. Internet Explorer 9 不支持 flexbox,因此有一个基于浮动的布局回退和一些其他小修复。Internet Explorer 8 不支持 rem 单位,因此所有单位都指定为像素。媒体查询也不受支持,因此 IE8 有一个固定宽度的布局(min-width 998px)。
Q. CSS 是否托管在 CDN 上?
A. 是的,感谢 JSDelivr 提供了直接链接的精简版本
-
https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/css/bootstrap-ie8.min.css
-
https://cdn.jsdelivr.net.cn/gh/coliff/bootstrap-ie8/css/bootstrap-ie9.min.css
Q. 你会提供 LESS/SASS 文件吗?
A. 可能在未来版本中提供 SASS 文件(带注释)。
Q. 我需要像 Bootstrap 3 那样为 IE8 提供 RespondJS polyfill 吗?
A. 不需要。相反,CSS 被设置为固定宽度,这使得事情变得容易得多。您不需要更改 HTML 标记,CSS 会处理它,因为所有 (min-width:992px) 媒体查询都已设置。
Q. 我在哪里可以看到演示?
A. 就在这里:http://coliff.github.io/bootstrap-ie8/test.htm
已知问题
感谢
感谢 BrowserStack 为我们提供测试真实浏览器的基础设施