nth

nth($list, $n)

Gets the nth item in a list.

Note that unlike some languages, the first item in a Sass list is number 1, the second number 2, and so forth.

This can return the nth pair in a map as well.

Negative index values address elements in reverse order, starting with the last element in the list.

Examples:

nth(10px 20px 30px, 1) => 10px
nth((Helvetica, Arial, sans-serif), 3) => sans-serif
nth((width: 10px, length: 20px), 2) => length, 20px

Parameters:

  • $list (Base)
  • $n (Number) The index of the item to get. Negative indices count from the end of the list.

Returns:

  • (Base)

Raises:

  • (ArgumentError) if $n isn’t an integer between 1 and the length of $list
doc_Sass
2016-11-11 13:09:17
Comments
Leave a Comment

Please login to continue.