我正在使用MVC4并通过nuget添加了Bootstrap和Font Awesome.
我可以看到Bootstrap如何通过下面的BootstrapBundleConfig.cs(由nuget包添加)捆绑在一起:
public static void RegisterBundles() { BundleTable.Bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap*")); BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap").Include("~/Content/bootstrap.css","~/Content/bootstrap-responsive.css")); }
我有以下问题:
>对于font-awesome,我没有看到上面类似的捆绑代码用于注册所需的css文件,有没有,或者我只是链接到内容目录中的样式表< link href =“〜/ Content / font-awesome.min.css“rel =”stylesheet“/> – 什么是正确的方法?
>对于bootstrap,如果我不想要响应式布局,我是否可以从Include注释掉bootstrap-responsive.css(“〜/ Content / bootstrap.css”,“〜/ Content / bootstrap-responsive.css”)) ?
解决方法
您可以阅读有关捆绑如何在
asp.net站点上工作的更多信息.
似乎BootStrap nuget包已经为你做了一些捆绑.您可以将其修改为在现有捆绑包中包含Font Awesome,或者将其设置为自己的捆绑包
例如
public static void RegisterBundles() { BundleTable.Bundles .Add(new ScriptBundle("~/bundles/bootstrap") .Include("~/Scripts/bootstrap*")); // Either add it to the existing bundle BundleTable.Bundles .Add(new StyleBundle("~/Content/bootstrap") .Include("~/Content/bootstrap.css","~/Content/bootstrap-responsive.css","~/Content/font-awesome.css")); // Or make it it's own bundle BundleTable.Bundles .Add(new StyleBundle("~/Content/font-awesome") .Include("~/Content/font-awesome.css")); }
然后,您需要确保_layout.cshtml呈现这些包(Bootstrap nuget可能没有为您完成此操作).
例如
@Styles.Render("~/Content/bootstrap") // Or,if you made it it's own bundle @Styles.Render("~/Content/font-awesome")
如果您不想在捆绑包中包含〜/ Content / bootstrap-responsive.css,只需从Include方法中删除此字符串即可.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。