index

index($list, $value)

Returns the position of a value within a list. If the value isn’t found, returns null instead.

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 position of a pair in a map as well.

Examples:

index(1px solid red, solid) => 2
index(1px solid red, dashed) => null
index((width: 10px, height: 20px), (height 20px)) => 2

Parameters:

  • $list (Base)
  • $value (Base)

Returns:

  • (Number, Null) The 1-based index of $value in $list, or null
doc_Sass
2016-11-11 13:09:10
Comments
Leave a Comment

Please login to continue.