3-3 nth()函数
本节编程练习不计算学习进度,请电脑登录imooc.com操作

nth()函数

语法:

nth($list,$n)

nth() 函数用来指定列表中某个位置的值。不过在 Sass 中,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'

 

任务

你可以写出下面函数运行出的结果吗?

  1.  
  2. nth(border-bottom (4px solid blue) black,2)
下一节