DotLess(.less)master.less文件,用于变量和函数

Cha*_*ell 3 css visual-studio-2010 chirpy dotless

有没有办法利用一个master.less文件来存放.less的所有必要的配置参数?

我有以下变量,我目前必须在我的解决方案中放在每个.less文件的顶部.

/* DOTLESS VARIABLES AND REUSABLE FUNCTIONS */
@brand_color: #9fdf40;                               /* Primary MySite Green */
@Color: #696969;                                     /* Alternate Text Color */
@top_gradient: #80cc15;                              /* MySite Green for TOP of GRADIENT */
@bottom_gradient: #9fdf40;                           /* MySite Green for BOTTOM of GRADIENT */
@borders: #696969;                                   /* Standard Gray Border */
@light_borders: #DDD;                                /* Lighter Gray Border */
@note: #ffffbe;                                      /* Yellow Notification Color (Also used for ad highlights) */
@font_family: Verdana, Arial, Helvetica, sans-serif; /*Standard MySite Font Family*/

.two-corner-radius(@radius){
    -webkit-border-top-left-radius: @radius;     /* Saf4+, Chrome */
    -moz-border-radius-topleft: @radius;         /* FF3.6+ */
    border-top-left-radius: @radius;             /* CSS3 */
    -webkit-border-bottom-right-radius: @radius; /* Saf4+, Chrome */
    -moz-border-radius-bottomright: @radius;     /* FF3.6+ */
    border-bottom-right-radius: @radius;         /* CSS3 */
}

.gradient(@from:@top_gradient, @to:@bottom_gradient, @fallback:@brand_color) {
    @ffgradient: "-moz-linear-gradient(center bottom, {0} 37%, {1} 72%)";
    @wkgradient: "-webkit-gradient(linear,left top,left bottom,color-stop(0.37, {0}), color-stop(0.72, {1}))";
    @iegradient: "progid:DXImageTransform.Microsoft.gradient(startColorstr='{1}', endColorstr='{0}')";
    @ie8gradient: "\"progid:DXImageTransform.Microsoft.gradient(startColorstr='{1}', endColorstr='{0}')\"";

    background : @fallback;                             /* for non-css3 browsers */
    background : formatstring(@ffgradient, @from, @to); /* FF3.6+ */
    background: formatstring(@wkgradient, @from, @to);  /* Saf4+, Chrome */
    filter: formatstring(@iegradient, @from, @to);      /* IE6,IE7 */
    -ms-filter: formatstring(@ie8gradient, @from, @to); /* IE8 */
}
/* END REUSABLE FUNCTIONS*/
Run Code Online (Sandbox Code Playgroud)

现在很明显,这比在css中编辑每个变量的每个实例更容易维护(如传统上那样),但是如果我可以声明一个master.less文件来保存变量和函数,然后拥有它,那将会更有益把我所有的"sub".less文件下载的CSS好看.

我目前正在使用Chirpy来管理我的.less文件,而后者又使用了dotless.core.dll

Cha*_*ell 8

原来有一个@import声明允许我导入我的master.less文件.我所要做的就是将它放在每个.less文件的顶部并使用其中包含的所有函数/变量.

@import "E:\Projects\MyApp\UI\Assets\Css\master.less";
Run Code Online (Sandbox Code Playgroud)

像冠军一样工作.