Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 table-responsive not working

I'm testing a local site in my phone (Lumia 920), the Bootstrap 3 site shows OK, but when I access to my local site my table doesn't look responsive. I even tried with the sample code of the Bootstrap page..

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's 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 you.

like image 549
Jesus Avatar asked Sep 15 '26 13:09

Jesus


1 Answers

Since IE10 on WP8 has some bugs regarding its processing of <meta name="viewport" content="width=device-width">, you need to apply the WP8 IE10-specific hack detailed in the 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 said to be fixed.

like image 176
cvrebert Avatar answered Sep 18 '26 10:09

cvrebert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!