Bootstrap and font-awesome in MVC4

I use MVC4 and added Bootstrap and Font Awesome via nuget.

I see how Bootstrap comes bundled through BootstrapBundleConfig.cs (which was added by the nuget package) below:

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

I have the following questions:

  • For font-awesome, I don’t see a similar linking code with the above for registering the necessary css files, is there any or just <link href="~/Content/font-awesome.min.css" rel="stylesheet" /> stylesheet in the content directory <link href="~/Content/font-awesome.min.css" rel="stylesheet" /> - what is the correct way?
  • For bootstrap, if I don't need a responsive layout, would I just comment out bootstrap-responsive.css from Include("~/Content/bootstrap.css", "~/Content/bootstrap-responsive.css")) ?
+6
source share
1 answer

More information on how the package works can be found on asp.net .

It seems that the BootStrap nuget package has made several packages for you. You can change this to include the Awesome font in an existing package or make it your own package

eg.

 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 own bundle BundleTable.Bundles .Add(new StyleBundle("~/Content/font-awesome") .Include("~/Content/font-awesome.css")); } 

Then you need to make sure your _layout.cshtml displays these packages (Bootstrap nuget may not have done this for you).

eg.

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

If you do not want to include ~ / Content / bootstrap-responsive.css in your package, simply remove this line from the Include method.

+8
source

Source: https://habr.com/ru/post/948267/


All Articles