我目前正在学习响应式设计,并遵循tutorial
我遇到的问题是教程请求我下载了最新的Zurb Foundataion库,将文件复制到CSS文件夹并通过BundleConfig.cs文件引用CSS。
我做到了这一点。我可以在我的css中看到3个文件(根据教程,foundation.css,foundation.min.css和normalize.css)。
然而,似乎我不需要第一个(因为我有.min版本),他们要求我使用的代码是
bundles.Add(new StyleBundle("~/Content/Foundation/css").Include(
"~/Content/css/foundation.min.css",
"~/Content/css/normalize.css"));
我从_Layout文件中引用此代码
@Styles.Render("~/Content/Foundation/css")
我遇到的问题是,网页没有按要求呈现。查看源代码向我显示问题
源代码仅显示
<link href="/Content/css/normalize.css" rel="stylesheet"/>
它没有渲染基础.min.css
所以,就像测试一样,我从_Layout文件中删除了
@Styles.Render("~/Content/Foundation/css")
并编码了以下2行
<link rel="stylesheet" href="~/Content/css/foundation.min.css"/>
<link rel="stylesheet" href="~/Content/css/normalize.css"/>
页面现在可以根据需要进行渲染。虽然我把它作为一个捆绑包添加起来时为什么它不起作用,但我输了......
这是BundleConfig.cs
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
//bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
// "~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/Foundation/css").Include(
"~/Content/css/foundation.min.css",
"~/Content/css/normalize.css"));
bundles.Add(new ScriptBundle("~/bundles/foundation").Include(
"~/Scripts/foundation/foundation.js",
"~/Scripts/foundation/foundation.*"));
}
}
我做错了什么?
答案 0 :(得分:3)
你应该在你的bundleconfig中使用它:
bundles.Add(new StyleBundle("~/Content/Foundation/css").Include(
"~/Content/css/foundation.css",
"~/Content/css/normalize.css"));
ASP.NET会自动看到有一个.min文件,当你没有处于调试模式时,它会占用.min文件,否则需要正常文件