IE8 issue with Twitter Bootstrap 3

后端 未结 22 2197
情歌与酒
情歌与酒 2020-11-22 13:48

I am creating a site using the new Twitter Bootstrap. The site looks fine and works in all required browsers except IE8.

In IE8 it seems to be displaying elements o

22条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 14:18

    I faced the same problem, tried the first answer but something was missing.

    If you guys are using Webpack, your css will be loaded as a style tag which is not supported by respond.js, it needs a file, so make sure bootstrap is loaded as a css file

    Personally I used extract-text-webpack-plugin

    const webpack = require("webpack")
    const ExtractTextPlugin = require("extract-text-webpack-plugin")
    const path = require("path")
    
    module.exports = {
        context: __dirname+"/src",
        entry: "./index.js",
        output: {
            filename: "./dist/bundle.js",
            path: __dirname
        },
        plugins: [
            ...,
            new ExtractTextPlugin("./dist/bootstrap.css", {
                allChunks: true
            })
        ],
        module: {
            loaders: [
                ...,
                // your css loader excluding bootstrap
                {
                    test: /\.css$/,
                    loader: "style!css",
                    exclude: [
                        path.resolve(__dirname, "node_modules/bootstrap/dist/css/bootstrap.css")
                    ]
                },
    
                {
                    // loads bootstrap as a file, change path accordingly if needs be, path needs to be absolute
                    include: [
                        path.resolve(__dirname, "node_modules/bootstrap/dist/css/bootstrap.css")
                    ],
                    loader: ExtractTextPlugin.extract("style-loader", "css-loader?minimize")
                }
            ]
        }
    }
    

    Hope it will help you

提交回复
热议问题