dotlesscss:如何更改导入器 dotlesscss 样式表中的变量值

发布于 11-18 11:36 字数 300 浏览 14 评论 0原文

我想使用基本样式表,其颜色定义为无点变量。 然后,根据我使用的颜色主题,我想更改此颜色。

- 基本样式表示例:

body
{
  color: @brand_color;
}

- 特定样式表示例,具体取决于我选择的配色方案:

@import "../BaseStyleSheet.less.css";

@brand_color: green;

如何实现此目的?

I would like to use a base stylesheet with the colours defined as dotless variables.
Then, depending on the color theme that I use I would like to change this colors.

- example of base stylesheet:

body
{
  color: @brand_color;
}

- Example of specific stylesheet, depending in the color scheme I pick:

@import "../BaseStyleSheet.less.css";

@brand_color: green;

How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〗斷ホ乔殘χμё〖2024-11-25 11:36:36

您需要将导入文件的扩展名更改为 .less

Less 仅编译以 .less 结尾的导入,如果它们以其他内容结尾,则它会按字面意思获取文件内容并将其插入到您的文件中。

另请注意,您可能必须在导入之前添加 @brand_color: green 声明,以便导入的文件可以访问它。

You need to change the extension of your imported file to .less

Less only compiles imports if they end in .less if they end in something else it takes the content of the file literally and just inserts it in your file.

Also note that you may have to put the @brand_color: green declaration before the import so the imported file can access it.

耳钉梦2024-11-25 11:36:36

导入文件的扩展名应为“.less”。

在 import 语句之后或之前更改变量值没有什么区别,它只是不会更改变量值,使得我想要的东西不可能实现。

“导入将无权访问主引用 Less 文件(或主文件中其他引用的 Less 文件)中的变量。这确保导入的 Less 文件不依赖于它们的使用位置。”

http:// enginechris.wordpress.com/2009/11/23/my-thoughts-on-using-dotless-and-the-less-syntax/

The extension of the imported file should be ".less".

Changing the variable value after or before the import statement makes no difference, it just doesn't change the variable value, making what I wanted not possible.

"Imports will not have access to variables in the main reference Less file (or other referenced Less files in the main one). This ensures that imported Less files have no dependencies on where they are been used."

http://enginechris.wordpress.com/2009/11/23/my-thoughts-on-using-dotless-and-the-less-syntax/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文