2013-06-27 2 views
6

MVC4を使用していて、ブートストラップとフォントAwesomeをnuget経由で追加しました。MVC4のブートストラップとfont-awesome

私は下に(nugetパッケージによって追加された)ブートストラップがBootstrapBundleConfig.cs経由でバンドルされますどのように見ることができます:私は、フォント素晴らしい用

  1. :私は、次の質問がある

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

    必要なCSSファイルを登録するための上記と同様のバンドルコードが表示されない、それがある、またはコンテンツディレクトリのスタイルシートにリンクするだけですか?<link href="~/Content/font-awesome.min.css" rel="stylesheet" /> - 適切な方法は何ですか?

  2. ブートストラップの場合、レスポンシブなレイアウトが必要ない場合は、からbootstrap-responsive.cssをコメントアウトするだけですか?

答えて

8

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は、(ブートストラップnugetがあなたのためにこれを行っていない可能性があります)これらのバンドルをレンダリングすることを確認する必要があります。

@Styles.Render("~/Content/bootstrap") 

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

あなたのバンドル内の〜/コンテンツ/ブートストラップ・responsive.cssを含めたくない場合は、簡単なInclude方法からこの文字列を削除します。