ASP.NET MVC4 Bundling with Twitter Bootstrap

后端 未结 4 1243
遇见更好的自我
遇见更好的自我 2020-12-02 10:21

I\'m trying to use the new bundling feature in MVC 4 with Twitter bootstrap and it seems to me like the paths to the glyphicons png-files int the css get\'s messed up in som

4条回答
  •  心在旅途
    2020-12-02 11:16

    The issue is most likely that the icons/images in the css files are using relative paths, so if your bundle doesn't live in the same app relative path as your unbundled css files, they become broken links.

    We have rebasing urls in css on our todo list, but for now, the easist thing to do is to have your bundle path look like the css directory so the relative urls just work, i.e:

    new StyleBundle("~/Static/Css/bootstrap/bundle")
    

    Update: We have added support for this in the 1.1beta1 release, so to automatically rewrite the image urls, you can add a new ItemTransform which does this rebasing automatically.

    bundles.Add(new StyleBundle("~/bundles/publiccss").Include(
                "~/Static/Css/bootstrap/bootstrap.css",
                "~/Static/Css/bootstrap/bootstrap-padding-top.css",
                "~/Static/Css/bootstrap/bootstrap-responsive.css",
                "~/Static/Css/bootstrap/docs.css", new CssRewriteUrlTransform()));
    

提交回复
热议问题