asp.Net   发布时间:2022-04-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了asp.net-mvc-4 – MVC4中的Bootstrap和font-awesome大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用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”)) ?

@H_673_11@

解决方法

您可以阅读有关捆绑如何在 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方法中删除此字符串即可.

@H_673_11@ @H_673_11@

大佬总结

以上是大佬教程为你收集整理的asp.net-mvc-4 – MVC4中的Bootstrap和font-awesome全部内容,希望文章能够帮你解决asp.net-mvc-4 – MVC4中的Bootstrap和font-awesome所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。