我在我的 BundleConfig.cs 文件中有以下︰
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/mainstyle.css",
"~/Content/layout/style.css", /* <<< HERE, the folder is different */
"~/Content/bootstrap.css",
"~/Content/site.css"));
和在 ~/Content/layout/style.css
文件︰
#page {
width: 1000px;
margin: 0 auto;
background: url(images/img04.jpg) repeat-y left top;
}
如果我们知道束将结合在一个单一的所有 css 之一 (?) 服务器如何将看到img04.img的链接 ( url(images/img04.jpg)
),作为 Content/images/
, Content/css/images/
或 Content/layout/images
?
一些谷歌搜索主题后看来, CssRewriteUrlTransform
类可确保图像 url 工作从动态捆绑 css 文件中,像这样︰
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/mainstyle.css",
"~/Content/bootstrap.css",
"~/Content/site.css")
.Include("~/Content/layout/style.css", new CssRewriteUrlTransform()));
如果这不能帮助,但你不过想使用捆绑,除以你捆绑在每个文件夹中的部分。将文件夹路径放"名字",像这样的捆绑中 new StyleBundle("~[folder_path]/[any word, like 'css' ot whatever you like]")
:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/mainstyle.css",
"~/Content/bootstrap.css",
"~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/layout/css").Include(
"~/Content/layout/style.css"));