Bootstrap and font-awesome in MVC4

前端 未结 1 595
渐次进展
渐次进展 2021-02-09 17:33

I am using MVC4 and have added Bootstrap and Font Awesome via nuget.

I can see how Bootstrap gets bundled in via BootstrapBundleConfig.cs (which was added b

相关标签:
1条回答
  • 2021-02-09 18:01

    You can read more about how bundling works on the asp.net site.

    It seems that the BootStrap nuget package has made some bundles for you. You could modify this to include Font Awesome in the existing bundle, or make it it's own bundle

    e.g.

    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"));
    
    }
    

    Then, you need to make sure that your _layout.cshtml renders these bundles (the Bootstrap nuget may not have done this for you).

    e.g.

    @Styles.Render("~/Content/bootstrap")
    
    // Or, if you made it it's own bundle
    @Styles.Render("~/Content/font-awesome")
    

    If you don't want to include ~/Content/bootstrap-responsive.css in your bundle, simple delete this string from the Include method.

    0 讨论(0)
提交回复
热议问题