css - 在另一个 mixins 中更改 mixins 参数

标签 css less mixins

我在另一个 mixins 中有一个 mixins

 .background(@url:  @base-url , @repeat: repeat, @pos1: left, @pos2: center, @color: transparent){
     background:@arguments;
 }

用于:

.divider{
    overflow:hidden;
    .background(@url: url("@{base-url}/divider.png") , @repeat: repeat-x, @pos2: bottom);
}

.class{
    .divider;

}

是否可以仅更改 .divider 混入中的 @pos2

最佳答案

当然可以,将参数添加到您的 .divider mixin 并按如下方式使用该参数:

.divider(@pos2: bottom) {
    overflow:hidden;
    .background(url("@{base-url}/divider.png"), repeat-x, @pos2);
}

.class{
    .divider(top); // you can use whatever value you want, or ignore it to use the default value 'bottom'
}

关于css - 在另一个 mixins 中更改 mixins 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24541172/

相关文章:

php - CSS 以斜线消失

html - 如何使用CSS制作边框三 Angular 形?

javascript - 通过javascript函数显示隐藏部分

css - LESS 中停止次数可变的线性梯度? (或萨斯)

python - 多个 mixin 和 __init__ 方法

font-awesome 的 css 样式无法正常工作

css - 从 Less 文件创建 CSS 文件

string - 如何在路径字符串中导入带有字符串插值的 .less 文件?

包含任何模块时的 Ruby 回调

ecmascript-6 - FlowType 是否支持混合或组合?