Scss 指定列表中某个位置的值

css yekong 680℃

nth(\(list,\)n)

nth() 函数用来指定列表中某个位置的值。不过在 Scss 中,nth() 函数和其他语言不同,
1 是指列表中的第一个标签值,
2 是指列给中的第二个标签值,依此类推。如:

>> nth(10px 20px 30px,1)
10px
>> nth((Helvetica,Arial,sans-serif),2)
"Arial"
>> nth((1px solid red) border-top green,1)
(1px "solid" #ff0000)

注:在 nth(\(list,\)n) 函数中的 $n 必须是大于 0 的整数:

>> nth((1px solid red) border-top green 1 ,0)
SyntaxError: List index 0 must be a non-zero integer for `nth'
喜欢 (0)