column are full width in IE 8 - Css bootstrap

前端 未结 4 1211
情歌与酒
情歌与酒 2021-02-07 07:49

I use bootstrap 3.0.3 in my web page and add html5shiv lib and respond lib for fix it this but it is not worked on internet explorer 8.

my html code:

<         


        
相关标签:
4条回答
  • 2021-02-07 08:40

    Based on the solution in the thread : Must Bootstrap container elements include row elements?, your markup should be :

    <div class="container">
        <div class="row">
            <div class="col-sm-4" style="background:red;">&nbsp;</div>
            <div class="col-sm-4" style="background:green;">&nbsp;</div>
            <div class="col-sm-4" style="background:blue;">&nbsp;</div>
        </div>
    </div>
    

    and use this CSS to achieve it in IE8:

    .container
    {
        display:table;
        width: 100%;
    }
    
    .row
    {
        height: 100%;
        display: table-row;
    }
    .col-sm-4
    {
        display: table-cell;
    }
    

    here is the working demo

    The .row class is not required inside a .container, but if you include then, container > row is the order not row > container (which you code)!

    EDIT

    It might be worth noting that respond.js only works for local files. So if you have got css files of bootstrap from CDN for your website on IE8, it won't work, instead, try with a local copy of bootstrap.css

    Internet Explorer 8 and Respond.js

    Beware of the following caveats when using Respond.js in your development and production environments for Internet Explorer 8.

    Respond.js and cross-domain CSS Using Respond.js with CSS hosted on a different (sub)domain (for example, on a CDN) requires some additional setup. See the Respond.js docs for details.

    Respond.js and file:// Due to browser security rules, Respond.js doesn't work with pages viewed via the file:// protocol (like when opening a local HTML file). To test responsive features in IE8, view your pages over HTTP(S). See the Respond.js docs for details.

    Respond.js and @import Respond.js doesn't work with CSS that's referenced via @import. In particular, some Drupal configurations are known to use @import. See the Respond.js docs for details.

    IE Compatibility modes Bootstrap is not supported in the old Internet Explorer compatibility modes. To be sure you're using the latest rendering mode for IE, consider including the appropriate tag in your pages:

    Source : Getbootstrap

    0 讨论(0)
  • 2021-02-07 08:40

    It might be better to apply this in a way that would only apply to IE and not any other browsers as it can break some of your responsive web sites. This page speaks specifically to how to apply IE only CSS.

    Apply CSS rules if browser is IE

    0 讨论(0)
  • 2021-02-07 08:43

    If "responsiveness" is not required, you can use col-xs-* classes instead of setting up proxy for respond.js. It works, because col-xs-* classes are media-agnostic. It solved the issue in my case.

    0 讨论(0)
  • 2021-02-07 08:45

    Addition you need remember that bootstrap.css is above respond.js in your head section:

    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- Mobile viewport optimisation -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Bootstrap example</title>
    
        <noscript>
            <link rel="stylesheet" href="../assets/css/noscript.css" />
        </noscript>
    
        <!-- Bootstrap -->
        <link href="../assets/bootstrap-3.3.5/dist/css/bootstrap.css" rel="stylesheet">
    
        <!--[if lte IE 8]>
        <script src="../assets/js/ie/es5-shim.min.js"></script>
        <script src="../assets/js/ie/es5-sham.min.js"></script>
        <script src="../assets/js/ie/html5shiv.js"></script>
        <script src="../assets/js/ie/respond.min.js"></script>
        <![endif]-->
    </head>
    
    0 讨论(0)
提交回复
热议问题