Sass 简介
Sass 安装
Sass 变量
Sass Nested Rules and Properties
Sass @import and Partials
Sass @mixin and @include
Sass @extend and Inheritance
Sass 函数
Sass String
Sass Numeric
Sass List
Sass Map
Sass Selector
Sass Introspection
Sass Color
Sass List - SASS基础教程 - 笔下光年
网站首页
Sass List
The list functions are used to access values in a list, combine lists, and add items to lists. Sass lists are immutable (they cannot change). So, the list functions that return a list, will return a new list, and not change the original list. Sass lists are 1-based. The first list item in a list is at index 1, not 0. The following table lists all list functions in Sass: | Function | Description & Example | |--------------|--------------------------| | append(list, value, [separator]) | Adds a single value to the end of the list. separator can be auto, comma, or space. auto is default. <br/><br/>**Example:**<br/>`append((a b c), d)`<br/>Result: `a b c d`<br/>`append((a b c), (d), comma)`<br/>Result: `a, b, c, d` | | index(list, value) | Returns the index position for the value in list. <br/><br/>**Example:**`index(a b c, b)`<br/>Result: `2`<br/>`index(a b c, f)`<br/>Result: `null` | | is-bracketed(list) | Checks whether the list has square brackets.<br/><br/>**Example:**<br/>`is-bracketed([a b c])`<br/>Result: `true`<br/>`is-bracketed(a b c)`Result: `false` | | join(list1, list2, [separator, bracketed]) | Appends list2 to the end of list1. separator can be auto, comma, or space. auto is default (will use the separator in the first list). bracketed can be auto, true, or false. auto is default. <br/><br/>**Example:**<br/>`join(a b c, d e f)`<br/>Result: `a b c d e f`<br/>`join((a b c), (d e f), comma)`<br/>Result: `a, b, c, d, e, f`<br/>`join(a b c, d e f, $bracketed: true)`<br/>Result: `[a b c d e f]` | | length(list) | Returns the length of the list. <br/><br/>**Example:**<br/>`length(a b c)`<br/>Result: `3` | | list-separator(list) | Returns the list separator used, as a string. Can be either space or comma. <br/><br/>**Example:**<br/>`list-separator(a b c)`<br/>Result: `"space"`<br/>`list-separator(a, b, c)`<br/>Result: `"comma"` | | nth(list, n) | Returns the nth element in the list. <br/><br/>**Example:**<br/>`nth(a b c, 3)`<br/>Result: `c` | | set-nth(list, n, value) | Sets the nth list element to the value specified. <br/><br/>**Example:**<br/>`set-nth(a b c, 2, x)`<br/>Result: `a x c` | | zip(lists) | Combines lists into a single multidimensional list. <br/><br/>**Example:**<br/>`zip(1px 2px 3px, solid dashed dotted, red green blue)`<br/>Result: `1px solid red, 2px dashed green, 3px dotted blue` |
上一篇:
Sass Numeric
下一篇:
Sass Map