2013-06-27 3 views
6

MVC4를 사용 중이며 부트 스트랩 및 글꼴 굉장을 nuget을 통해 추가했습니다.MVC4에서 부트 스트랩 및 글꼴 굉장

내가 부트 스트랩이되어 (nuget 패키지가 추가 된) BootstrapBundleConfig.cs를 통해에 번들로 제공되는 방식을 볼 수 있습니다

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

나는 다음과 같은 질문이 있습니다에 대한

  1. 을 글꼴 최고, I 필요한 CSS 파일을 등록 할 때 위와 유사한 번들 코드가 표시되지 않습니다. 아무 것도 없거나 콘텐츠 디렉토리의 스타일 시트에 연결 만하면됩니까? <link href="~/Content/font-awesome.min.css" rel="stylesheet" /> - 적절한 방법은 무엇입니까?
  2. 부트 스트랩의 경우 반응 형 레이아웃을 원하지 않는다면 에서 bootstrap-responsive.css를 주석 처리하면됩니까?

답변

8

번들링 작동 방법에 대한 자세한 내용은 asp.net 사이트에서 확인할 수 있습니다.

BootStrap Nuget 패키지가 일부 번들을 만든 것으로 보입니다. 이 글꼴을 수정하여 기존 번들에 글꼴 썸네일을 포함 시키거나 자체 번들로 만들 수 있습니다.

예 :

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

} 

그런 다음, 당신은 (부트 스트랩 nuget 당신을 위해 이런 짓을하지 않았을 수 있습니다) 당신의 _layout.cshtml이 번들을 렌더링 있는지 확인해야합니다.

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

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

당신이 당신의 번들 ~/컨텐츠/부트 스트랩 - responsive.css을 포함하지 않는 경우, 간단하게 Include 방법에서이 문자열을 삭제합니다.