Jam*_*123 49 css fonts twitter-bootstrap font-awesome asp.net-mvc-5
如果我直接参考font-awesome.css_layouts页面.它会工作
<link href="~/Content/font-awesome-4.0.3/css/font-awesome.css" rel="stylesheet" />
Run Code Online (Sandbox Code Playgroud)
但我用过BundleConfig.cs.图标未显示.
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/font-awesome-4.0.3/css/font-awesome.css",
"~/Content/bootstrap.css",
"~/Content/body.css",
"~/Content/site.css",
"~/Content/form.css"
));
Run Code Online (Sandbox Code Playgroud)
而且我观察到浏览器控制台对字体目录有错误.
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51130/fonts/fontawesome-webfont.woff?v=4.0.3
可能是什么问题呢?
Sim*_*n C 100
如本文所述,请CssRewriteUrlTransform在捆绑时尝试使用:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/body.css",
"~/Content/site.css",
"~/Content/form.css"
).Include("~/Content/font-awesome-4.0.3/css/font-awesome.css", new CssRewriteUrlTransform());
Run Code Online (Sandbox Code Playgroud)
这会将css文件中任何资产的URL更改为绝对URL,因此捆绑不会弄乱相对路径.
MSDN链接:CssRewriteUrlTransform
har*_*eyt 10
我的解决方案很简单:运行PM> Install-Package FontAwesome,并引用正确的路径:
.Include("~/Content/font-awesome.min.css")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37565 次 |
| 最近记录: |