Skip to content

Commit

Permalink
fixes #10497: Fix Windows 8 and Windows Phone 8 behavior and apply it…
Browse files Browse the repository at this point in the history
… to the docs
  • Loading branch information
mdo authored and cvrebert committed Sep 11, 2013
1 parent 37933a9 commit 6519303
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 26 deletions.
15 changes: 15 additions & 0 deletions assets/js/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@

$(function(){

// IE10 viewport hack for Surface/desktop Windows 8 bug
//
// See Getting Started docs for more information
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
);
document.getElementsByTagName("head")[0].
appendChild(msViewportStyle);
}


var $window = $(window)
var $body = $(document.body)

Expand Down
6 changes: 0 additions & 6 deletions dist/css/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -6348,12 +6348,6 @@ body.modal-open,
width: device-width;
}

@media screen and (max-width: 400px) {
@-ms-viewport {
width: 320px;
}
}

.hidden {
display: none !important;
visibility: hidden !important;
Expand Down
2 changes: 1 addition & 1 deletion dist/css/bootstrap.min.css

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,12 @@ <h3>IE Compatibility modes</h3>
{% endhighlight %}
<p>See <a href="http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge">this StackOverflow question</a> for more information.</p>

<h3>Windows Phone 8 and Internet Explorer 10</h3>
<p>Internet Explorer 10 doesn't differentiate device width from viewport width, and thus doesn't properly apply the media queries in Bootstrap's CSS. To address this, you can optionally include the following CSS and JavaScript to work around this problem until Microsoft issues a fix.</p>
<h3>Internet Explorer 10 in Windows 8 and Windows Phone 8</h3>
<p>Internet Explorer 10 doesn't differentiate <strong>device width</strong> from <strong>viewport width</strong>, and thus doesn't properly apply the media queries in Bootstrap's CSS. Normally you'd just add a quick snippet of CSS to fix this:</p>
{% highlight css %}
@-ms-viewport { width: device-width; }
{% endhighlight %}
<p>However, this doesn't work as it causes Windows Phone 8 devices to show a mostly desktop view instead of narrow "phone" view. To address this, you'll need to <strong>include the following CSS and JavaScript to work around the bug until Microsoft issues a fix</strong>.</p>
{% highlight css %}
@-webkit-viewport { width: device-width; }
@-moz-viewport { width: device-width; }
Expand All @@ -749,6 +753,7 @@ <h3>Windows Phone 8 and Internet Explorer 10</h3>
}
{% endhighlight %}
<p>For more information and usage guidelines, read <a href="http://timkadlec.com/2013/01/windows-phone-8-and-device-width/">Windows Phone 8 and Device-Width</a>.</p>
<p>As a heads up, we include this in the Bootstrap docs as an example.</p>

<h3>Safari percent rounding</h3>
<p>In the latest Safari for Mac, its rendering engine has a little trouble with the long decimal places of our <code>.col-*-1</code> grid classes, meaning if you have 12 individual columns you'll notice they come up short compared to other rows of columns. We can't do much here (<a href="https://github.com/twbs/bootstrap/issues/9282">see #9282</a>) but you do have some options:</p>
Expand Down
32 changes: 15 additions & 17 deletions less/responsive-utilities.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@
// --------------------------------------------------


// IE10 Metro responsive
// Required for Windows 8 Metro split-screen snapping with IE10
// IE10 in Windows (Phone) 8
//
// Support for responsive views via media queries is kind of borked in IE10, for
// both Surface/desktop in split view and for Windows Phone 8. This particular fix
// must be accompanied by a snippet of JavaScript to sniff the user agent and
// apply some conditional CSS to *only* the Surface/desktop Windows 8. Look at
// our Getting Started page for more information on this bug.
//
// For more information, see the following:
//
// Issue: https://github.com/twbs/bootstrap/issues/10497
// Source: http://timkadlec.com/2012/10/ie10-snap-mode-and-responsive-design/
@-ms-viewport{

@-ms-viewport {
width: device-width;
}

// IE10 on Windows Phone 8
// IE10 on WP8 doesn't report CSS pixels, but actual device pixels. In
// other words, say on a Lumia, you'll get 768px as the device width,
// meaning users will see the tablet styles and not phone styles.
//
// Alternatively you can override this with JS (see source below), but
// we won't be doing that here given our limited scope.
//
// Source: http://timkadlec.com/2013/01/windows-phone-8-and-device-width/
@media screen and (max-width: 400px) {
@-ms-viewport{
width: 320px;
}
}

// Hide from screenreaders and browsers
//
// Credit: HTML5 Boilerplate

.hidden {
display: none !important;
visibility: hidden !important;
}


// Visibility utilities

.visible-xs {
Expand Down

0 comments on commit 6519303

Please sign in to comment.