css - 如何使用 WebOptimization 和 Bundling 将 CSS 添加到 ASP.NET 站点

标签 css asp.net twitter-bootstrap

我创建了一个 ASP.NET 表单站点作为沙箱,并使用 NuGet 添加了我刚刚学习的 Bootstrap。想换个主题,于是下载了一个主题,把最小化后的文件改名为theme1-bootstrap.min.css。如果我只是替换现有的 boostrap.min.css,一切都会按预期进行。

但是,我在想(可能是错误的)这不是一个好主意,最好在原始 bootstrap.min.css 之后加载我的主题 bootstrap.min.css。这就是我正在使用的引用对 html 文件中的语句所做的。

但是 ASP.NET 元素与我使用的 html 引用有点不同,我在任何地方都找不到任何语句。我认为它与 Bundle.config 或 site.master 中的行有关 <webopt:bundlereference runat="server" path="~/Content/css" />

如果我知道发生了什么以及应用我的主题的最佳实践是什么,我将不胜感激。谢谢。

最佳答案

看看 ~/AppStart/BundleConfig.cs:

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));

这意味着 Web 优化将搜索文件 bootstrap.csssite.css 原样或带有 ​​.min 后缀的文件。 因此,如果您需要将 theme1-bootstrap.min.css 添加到 bundle - 您需要像这样扩展它:

    bundles.Add(new StyleBundle("~/Content/css").Include(
              "~/Content/bootstrap.css",
              "~/Content/site.css",
              "~/Content/theme1-bootstrap.css"));

关于css - 如何使用 WebOptimization 和 Bundling 将 CSS 添加到 ASP.NET 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23969816/

相关文章:

html - 我可以将 webpack 'copyFiles' 与 twig.paths 配置结合使用吗

jquery - Bootstrap : Implement facebook-like notifications in header (navbar) as submenu, 不仅仅是一个计数器

javascript - 在 HTML 中链接 JavaScript 对象

asp.net - 增量或按需 sitemap.xml

c# - 在运行时在服务器端在 C# 中查找 div

html - 如何在两个 Bootstrap 列之间直接添加两行?

CSS 2 Div 布局 float

.net - margin :0 auto; not working for the whole page

javascript - 不使用 jQuery 突出显示事件 anchor 链接

c# - 如何对控件同时使用 JavaScript 验证和 asp.net 验证