ahm*_*iee 1 c# asp.net asp.net-mvc bundle asp.net-mvc-4
我想在我的代码中捆绑三个css文件.其中一个是我的网络字体,我使用'url'.但是当我运行应用程序浏览器时找不到文件.
这是我的css文件:
@font-face {
font-family: 'neuropol';
src: url('../Files/Font/neuropol_x_free-webfont.eot');
src: url('../Files/Font/neuropol_x_free-webfont.eot?#iefix') format('embedded-opentype'),
url('../Files/Font/neuropol_x_free-webfont.woff') format('woff'),
url('../Files/Font/neuropol_x_free-webfont.ttf') format('truetype'),
url('../Files/Font/neuropol_x_free-webfont.svg#neuropol_x_freeregular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
这是我的捆绑代码:
bundles.Add(new StyleBundle("~/bundles/styles/base").Include("~/Content/Styles/style.css", "~/Content/Styles/normalize.css", "~/Content/Styles/webfont.css"));
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗?
当CSS定义中有src URL时,浏览器将检查相对于下载CSS文件的位置的路径.在这种情况下,这意味着它正在寻找src文件 ~/bundles/Files/Font/...
而不是~/Content/Files/Font/...
.
尝试使您的包名称与相对位置匹配.
bundles.Add(new StyleBundle("~/Content/Styles/base-bundle.css").Include("~/Content/Styles/style.css", "~/Content/Styles/normalize.css", "~/Content/Styles/webfont.css"));
Run Code Online (Sandbox Code Playgroud)