你的位置:首页 > ASP.net教程

[ASP.net教程]MVC引用CSS文件の正确姿势


你的css文件目录结构:

 

将路径写入BundleConfig规则中:

 1 using System.Web; 2 using System.Web.Optimization; 3  4 namespace XXXX 5 { 6   public class BundleConfig 7   { 8     public static void RegisterBundles(BundleCollection bundles) 9     {10       bundles.Add(new StyleBundle("~/Content/cssSelf").Include(11         "~/Content/css/bootstrap.css",12         "~/Content/css/etalage.css",13         "~/Content/css/flexslider.css",14         "~/Content/css/megamenu.css",15         "~/Content/css/style.css"16         ));17     }18   }19 }

View Code

 

前端引用:

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

 

大    功    告    成!