Bootstrap 4 for IE8 and IE9

bootstrap-ie8

​编辑 ​编辑 ​编辑 ​编辑 ​编辑

Bootstrap 4 for IE8 and IE9

Bootstrap 4 drops support for Internet Explorer 8 and 9, but you can add it back by simply adding a conditional statement targeting IE 8 and 9 with a CSS file and a CDN-hosted JavaScript file to polyfill HTML5 element support.

Quick start

Several quick start options are available:

  • Download the latest release
  • Clone the repo git clone https://github.com/coliff/bootstrap-ie8.git
  • Install with npm npm install bootstrap-ie8
  • Install with yarn yarn add bootstrap-ie8
  • Install with Composer composer require coliff/bootstrap-ie8:4.3.1

Usage

  1. Add to the top of the <head> of your page<meta http-equiv="x-ua-compatible" content="ie=edge">

  2. Add the following conditional statements to the of your page but after the Bootstrap 4 CSS:<head>

<span style="color:#24292e"><span style="background-color:#ffffff"><span style="background-color:#f8f8f8"><span style="background-color:#f6f8fa"><code><span style="color:#999988"><em><!--[if IE 9]>
  <link href="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie9.min.css" rel="stylesheet">
<![endif]--></em></span>
<span style="color:#999988"><em><!--[if lte IE 8]>
  <link href="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie8.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/g/html5shiv@3.7.3"></script>
<![endif]--></em></span>
</code></span></span></span></span>
Optional JavaScript Fix

To fix the dropdown menus and modals you can add the following to the footer:

<span style="color:#24292e"><span style="background-color:#ffffff"><span style="background-color:#f8f8f8"><span style="background-color:#f6f8fa"><code><span style="color:#999988"><em><!--[if gte IE 9]><!--></em></span>
  <span style="color:#000080"><script </span><span style="color:#008080">src=</span><span style="color:#dd1144">"https://code.jquery.com/jquery-3.5.1.slim.min.js"</span><span style="color:#000080">></script></span>
  <span style="color:#000080"><script </span><span style="color:#008080">src=</span><span style="color:#dd1144">"https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"</span><span style="color:#000080">></script></span>
<span style="color:#999988"><em><!--<![endif]--></em></span>
<span style="color:#999988"><em><!--[if IE 9]>
  <script src="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/js/bootstrap-ie9.min.js"></script>
<![endif]--></em></span>
<span style="color:#999988"><em><!--[if lte IE 8]>
  <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
  <script src="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/js/bootstrap-ie8.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.js"></script>
<![endif]--></em></span>
</code></span></span></span></span>

This will load jQuery, PopperJS and Bootstrap as normal on all browsers other than IE8. IE9 will load the script. IE8 will load the latest compatible version of jQuery, the unminified Bootstrap JS (the minified version causes an error) and the fix.bootstrap-ie9.jsbootstrap-ie8.js

FAQS

Q. What does this fix/polyfill?

A. Internet Explorer 9 doesn’t support flexbox so there is a float-based layout fallback and a couple of other minor fixes. Internet Explorer 8 doesn’t support rem units so all units are specified in pixels. Media Queries are also not supported so IE8 has a fixed-width layout (min-width 998px).

Q. Is the CSS hosted on a CDN?

A. Yes, thanks to JSDelivr minified versions are available with the direct links:

  • https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie8.min.css

  • https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie9.min.css

Q. Will you provide LESS/SASS files?

A. Maybe in a future release I’ll provide SASS file (with comments).

Q. Do I need the RespondJS polyfill for IE8 like Bootstrap 3 uses?

A. No. Instead the CSS is set to be fixed-width which makes things a lot easier. You don’t need to change your HTML markup, the CSS will take care of it as the (min-width:992px) media queries are all set.

Q. Where can I see a demo?

A. Right here: Bootstrap for IE8 and IE9 Test Page

Known Issues

Thanks

​编辑

Thanks to BrowserStack for providing the infrastructure that allows us to test in real browsers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小白的编程日志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值