【发布时间】:2015-03-06 15:56:02
【问题描述】:
我正在查看由其他人 (Chris Eppstein) 创建的 gradients mixin。在主 mixin 的参数列表中,最后一个参数后面有三个点。
@mixin linear-gradient($direction, $color-stops...){
它们是什么意思?我在文档中找不到它,主要是因为 ... 在许多代码示例中用于显示它们何时跳过了不相关的部分。
谢谢
【问题讨论】:
我正在查看由其他人 (Chris Eppstein) 创建的 gradients mixin。在主 mixin 的参数列表中,最后一个参数后面有三个点。
@mixin linear-gradient($direction, $color-stops...){
它们是什么意思?我在文档中找不到它,主要是因为 ... 在许多代码示例中用于显示它们何时跳过了不相关的部分。
谢谢
【问题讨论】:
在这种情况下,$color-stops 是一个 arglist。它为您提供了将任意数量的参数传递给 mixin 并根据需要使用它的可能性。
例如:
@mixin linear-gradient($direction, $color-stops...){
background-color: nth($color-stops,1);
color: nth($color-stops,2);
}
你可以这样调用这个函数:
.foo {
@include linear-gradient(to right, blue, white, red, black);
}
【讨论】: