Bootstrap 3 is not responsive to tables

I am testing a local site on my phone (Lumia 920), Bootstrap 3 site shows OK, but when I access my local site my spreadsheet does not appear responsive. I even tried with the sample Bootstrap page code.

Here is my code:

<!DOCTYPE html>
<html lang="en">
<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 101 Template</title>

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

    <!-- Optional theme -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

    <!-- jQuery (necessary for Bootstrap JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    <!-- Latest compiled and minified JavaScript -->
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body data-twttr-rendered="true">
<div class="container">
    <div class="row">
        <div class="col-md-9">
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th></th>
                        <th>
                            Extra small devices
                            <small>Phones (&lt;768px)</small>
                        </th>
                        <th>
                            Small devices
                            <small>Tablets (β‰₯768px)</small>
                        </th>
                        <th>
                            Medium devices
                            <small>Desktops (β‰₯992px)</small>
                        </th>
                        <th>
                            Large devices
                            <small>Desktops (β‰₯1200px)</small>
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <th class="text-nowrap">Grid behavior</th>
                        <td>Horizontal at all times</td>
                        <td colspan="3">Collapsed to start, horizontal above breakpoints</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Container width</th>
                        <td>None (auto)</td>
                        <td>750px</td>
                        <td>970px</td>
                        <td>1170px</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Class prefix</th>
                        <td><code>.col-xs-</code></td>
                        <td><code>.col-sm-</code></td>
                        <td><code>.col-md-</code></td>
                        <td><code>.col-lg-</code></td>
                    </tr>
                    <tr>
                        <th class="text-nowrap"># of columns</th>
                        <td colspan="4">12</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Column width</th>
                        <td class="text-muted">Auto</td>
                        <td>~62px</td>
                        <td>~81px</td>
                        <td>~97px</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Gutter width</th>
                        <td colspan="4">30px (15px on each side of a column)</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Nestable</th>
                        <td colspan="4">Yes</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Offsets</th>
                        <td colspan="4">Yes</td>
                    </tr>
                    <tr>
                        <th class="text-nowrap">Column ordering</th>
                        <td colspan="4">Yes</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-md-3">
            asd
        </div>
    </div>
</div>
</body>
</html>

      

What am I doing wrong? Thank.

+3


source to share


1 answer


Since IE10 on WP8 has some bugs regarding handling <meta name="viewport" content="width=device-width">

, you need to apply WP8 IE10-specific hack mentioned in Bootstrap documentation :

Add this CSS:

@-webkit-viewport   { width: device-width; }
@-moz-viewport      { width: device-width; }
@-ms-viewport       { width: device-width; }
@-o-viewport        { width: device-width; }
@viewport           { width: device-width; }

      



And this JavaScript:

if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
  var msViewportStyle = document.createElement('style');
  msViewportStyle.appendChild(
    document.createTextNode(
      '@-ms-viewport{width:auto!important}'
    )
  );
  document.querySelector('head').appendChild(msViewportStyle)
}

      

Or you can wait for Windows Phone 8.1 where the bug is fixed.

+2


source







All Articles