1

我有一个 Rails 3.2 应用程序,其中每个用户都有自己的子域。他能够改变一些事物的外观和感觉。在 Bootstrap 之前我这样做的方式是:

1) Keep a template of a customizable CSS file.

2) Solicit input for certain CSS settings via a form.

3) On form submission, write a new CSS file based on the template, but with the new settings.

4) Associate the new CSS file with that partiular subdomain, and serve it up when the subdomain is accessed via the main layout template.

这样做有点难看,但效果很好。此后,我通过 twitter-bootstrap-rails gem 迁移了应用程序以使用 Twitter Bootstrap。这使我能够清理大量代码。我现在要做的是清理这个 CSS 自定义功能。

我想仅基于更改 Twitter Bootstrap LESS 变量来进行新的 CSS 更改。我的子域的新 LESS 文件将像这样生成:

@bodyBackground: #ffffff;

@navbarLinkColor: #ffffff;

@navbarText: #ffffff;

@headingsColor: #666666;

@linkColor: #000000;

@navbarBackgroundHighlight: #000000;

@baseFontFamily: Verdana, Tahoma, Geneva, sans-serif;

请注意,仅variables在此文件中。所有设置都在 Bootstrap 代码中。因此,保存后,我需要动态重新编译所有 Boostrap CSS。几个问题:

1)这甚至可能吗?如果这些变量已经在 Twitter Bootstrap 中设置为默认值,我该如何覆盖它们?

2)我是不是走错了路?我认为它会更干净,但我开始怀疑。

4

1 回答 1

0

我需要做的就是将它添加到 LESS 文件的顶部:

@import "bootstrap_and_overrides.css.less";

这照顾了一切。干净多了!!!

于 2013-02-28T14:44:03.197 回答