我正在编写一个ASP.NET MVC应用程序,并计划使用LESS作为使用Dotless编译器的样式表。我想让我的应用程序可换肤,并发现我可以使用LESS变量来自定义样式。DOTLESS - 用户特定变量
我该如何最好地执行此操作?
我想能够覆盖嵌套层次结构中的变量。我有一个网站广泛的变量。其中包含所有变量。我现在想让每一组客户都有他们特定的覆盖。然后,我希望每个客户都有自己的覆盖,但是如果某些变量未定义,则使用“组默认值”。然后我想要“用户”覆盖(每个客户有几个用户)。
我想到的另一种方法是创建一个variables.default.less文件来定义所有变量。然后我创建一个“覆盖”文件,重新定义只更改的变量。这允许我创建一个用户特定的较少文件来包含所有嵌套变量覆盖。
实例:
variables.default.less
@bgcolor: #ffffff;
@textcolor: #000000;
@fontsize: 12px;
@logo: "site-default.png";
variables.customergroup01.less
@bgcolor: #cccccc;
@textcolor: #999999;
variables.customer99.less
@logo: "customer-logo99.png";
variables.user1234。少于
@font-size: 18px;
现在,如果客户55级的日志中(他属于customergroup01),他得到了以下的样式表
// Import default vars
@import "variables.default.less";
// Import customized vars
@import "variables.customergroup01.less";
// This is the actual stylesheet
@import "styles.less";
现在,如果用户1234(客户99和customergroup01),他得到了以下的样式表
// Import default vars
@import "variables.default.less";
// Import customized vars
@import "variables.customergroup01.less";
@import "variables.customer99.less";
@import "variables.user1234.less";
// This is the actual stylesheet
@import "styles.less";
这是一个可用的模式? 我是否即时渲染定制的较少文件或创建某种方式预编译它们?
谢谢!
你有没有解决你的难题,并且你想和我们分享 – lordkain
考虑阅读http://stackoverflow.com/questions/10797661/changing-dotless-parameters-dynamically和http://stackoverflow.com /问题/ 17276966 /如何对变化值动态变量 –