Asp.net
與 Twitter Bootstrap 捆綁的 ASP.NET MVC4
我正在嘗試將 MVC 4 中的新捆綁功能與 Twitter 引導程序一起使用,在我看來,css get 中的 glyphicons png-files 的路徑在某種程度上被搞砸了。這是我的程式碼:
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")); bundles.Add(new ScriptBundle("~/bundles/publicjs").Include( "~/Static/Js/jquery-1.7.2.js", "~/Static/Js/bootstrap/bootstrap.js", "~/Static/Js/cookie/jquery.cookie.js"));我沒有在按鈕上看到任何圖示,同樣。我在這裡做錯了嗎?有什麼建議?
問題很可能是 css 文件中的圖示/圖像使用了相對路徑,因此如果您的捆綁包與未捆綁的 css 文件不在同一個應用程序相對路徑中,它們就會成為斷開的連結。
我們在待辦事項列表中的 css 中重新設置了 url,但現在,最簡單的做法是讓你的 bundle 路徑看起來像 css 目錄,這樣相對 url 就可以工作,即:
new StyleBundle("~/Static/Css/bootstrap/bundle")**更新:**我們在 1.1beta1 版本中添加了對此的支持,因此要自動重寫圖像 url,您可以添加一個新的 ItemTransform 來自動執行此變基。
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()));