Mobile-First Responsive Design IE 8 Widescreen Compatibility

594 views Asked by At

Here is a link to the page I'm working on.

I've switched over to Bootstrap 3's mobile-first framework. The main difference is that instead of defaulting to a wide layout and using media queries to shrink down to mobile sizes, the default size is mobile and media queries are used to for wider resolutions:

So instead of:

@media (max-width: 767px) {}

We now use:

@media (min-width: 768px) {}

When using the old way, IE 8 (which doesn't support media queries) would display the page in its widest format. However now it displays the page in its mobile format, which is not desirable.

Is there any way to get the page to default to the widest layout when media queries are not supported? I include respond.js but have had no luck:

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
        <script src="js/html5shiv.js"></script>
        <script src="js/respond.min.js"></script>
    <![endif]-->
1

There are 1 answers

0
Spoeken On BEST ANSWER

A fix that gets you a long way: Add a stylesheet for ltie9

<!--[if lt IE 9]>
    <link href="styles/css/ltie9.css" rel="stylesheet" type="text/css">
<![endif]-->

Copy and paste the styling for cols, push and offset from the media query of your choosing (You find this in grid.less) into ltie9.less. i.ex. the medium size:

Its has to be less, you need to include variables.less as well. Or you can replace all the widths width a percentage of your choosing, but why would you?

// Core variables
@import "variables.less";

body {
  .container {
    max-width: @container-desktop;
  }
  .col-md-1,
  .col-md-2,
  .col-md-3,
  .col-md-4,
  .col-md-5,
  .col-md-6,
  .col-md-7,
  .col-md-8,
  .col-md-9,
  .col-md-10,
  .col-md-11 {
    float: left;
  }
  .col-md-1  { width: percentage((1 / @grid-columns)); }
  .col-md-2  { width: percentage((2 / @grid-columns)); }
  .col-md-3  { width: percentage((3 / @grid-columns)); }
  .col-md-4  { width: percentage((4 / @grid-columns)); }
  .col-md-5  { width: percentage((5 / @grid-columns)); }
  .col-md-6  { width: percentage((6 / @grid-columns)); }
  .col-md-7  { width: percentage((7 / @grid-columns)); }
  .col-md-8  { width: percentage((8 / @grid-columns)); }
  .col-md-9  { width: percentage((9 / @grid-columns)); }
  .col-md-10 { width: percentage((10/ @grid-columns)); }
  .col-md-11 { width: percentage((11/ @grid-columns)); }
  .col-md-12 { width: 100%; }

  // Push and pull columns for source order changes
  .col-md-push-0  { left: auto; }
  .col-md-push-1  { left: percentage((1 / @grid-columns)); }
  .col-md-push-2  { left: percentage((2 / @grid-columns)); }
  .col-md-push-3  { left: percentage((3 / @grid-columns)); }
  .col-md-push-4  { left: percentage((4 / @grid-columns)); }
  .col-md-push-5  { left: percentage((5 / @grid-columns)); }
  .col-md-push-6  { left: percentage((6 / @grid-columns)); }
  .col-md-push-7  { left: percentage((7 / @grid-columns)); }
  .col-md-push-8  { left: percentage((8 / @grid-columns)); }
  .col-md-push-9  { left: percentage((9 / @grid-columns)); }
  .col-md-push-10 { left: percentage((10/ @grid-columns)); }
  .col-md-push-11 { left: percentage((11/ @grid-columns)); }

  .col-md-pull-0  { right: auto; }
  .col-md-pull-1  { right: percentage((1 / @grid-columns)); }
  .col-md-pull-2  { right: percentage((2 / @grid-columns)); }
  .col-md-pull-3  { right: percentage((3 / @grid-columns)); }
  .col-md-pull-4  { right: percentage((4 / @grid-columns)); }
  .col-md-pull-5  { right: percentage((5 / @grid-columns)); }
  .col-md-pull-6  { right: percentage((6 / @grid-columns)); }
  .col-md-pull-7  { right: percentage((7 / @grid-columns)); }
  .col-md-pull-8  { right: percentage((8 / @grid-columns)); }
  .col-md-pull-9  { right: percentage((9 / @grid-columns)); }
  .col-md-pull-10 { right: percentage((10/ @grid-columns)); }
  .col-md-pull-11 { right: percentage((11/ @grid-columns)); }

  // Offsets
  .col-md-offset-0  { margin-left: 0; }
  .col-md-offset-1  { margin-left: percentage((1 / @grid-columns)); }
  .col-md-offset-2  { margin-left: percentage((2 / @grid-columns)); }
  .col-md-offset-3  { margin-left: percentage((3 / @grid-columns)); }
  .col-md-offset-4  { margin-left: percentage((4 / @grid-columns)); }
  .col-md-offset-5  { margin-left: percentage((5 / @grid-columns)); }
  .col-md-offset-6  { margin-left: percentage((6 / @grid-columns)); }
  .col-md-offset-7  { margin-left: percentage((7 / @grid-columns)); }
  .col-md-offset-8  { margin-left: percentage((8 / @grid-columns)); }
  .col-md-offset-9  { margin-left: percentage((9 / @grid-columns)); }
  .col-md-offset-10 { margin-left: percentage((10/ @grid-columns)); }
  .col-md-offset-11 { margin-left: percentage((11/ @grid-columns)); }
}