dotlesscss:如何更改导入器 dotlesscss 样式表中的变量值
我想使用基本样式表,其颜色定义为无点变量。 然后,根据我使用的颜色主题,我想更改此颜色。
- 基本样式表示例:
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 技术交流群。

发布评论
评论(2)
耳钉梦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/
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您需要将导入文件的扩展名更改为 .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.