Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Sass Selector Functions

Sass Selector Functions

Sass Functions Sass Functions

Sass selector functions are used to inspect and process selectors.

The following table lists Sass's selector functions:

function Description & Examples
is-superselector(super, sub) Compare the matching scope of two selectors, that is, determine whether super the selector contains sub the scope matched by the selector; return true if so, otherwise false.
 **实例:**       

 is-superselector("div", "div.myInput")       

 结果: true       

 is-superselector("div.myInput", "div")       

 结果: false       

 is-superselector("div", "div")       

 结果: true |

| selector-append(selectors) | Append the second (or multiple) to the end of the first selector. selector.

 **实例:**       

 selector-append("div", ".myInput")       

 结果: div.myInput       

 selector-append(".warning", "__a")       

 结果: .warning__a |

| selector-extend(selector, extendee, extender) |   | | selector-nest(selectors) | Return a new selector that generates a nested list from the provided list selector.

 **实例:**       

 selector-nest("ul", "li")       

 结果: ul li       

 selector-nest(".warning", "alert", "div")       

 结果: .warning div, alert div |

| selector-parse(selector) | Convert the string's selector selector into a selector list.

 **实例:        

**selector-parse("h1 .myInput .warning")
Result: ('h1' '.myInput' '.warning') | | selector-replace(selector, original, replacement) | Given a selector, replace original with replacement and return a new selector list.

 **实例:**       

 selector-replace("p.warning", "p", "div")       

 结果: div.warning |

| selector-unify(selector1, selector2) | Combine two sets of selectors into a compound selector. If the two selectors cannot be combined, return null.

 **实例:**       

 selector-unify("myInput", ".disabled")       

 结果: myInput.disabled       

 selector-unify("p", "h1")       

 结果: null |

| simple-selectors(selectors) | Split a compound selector into individual selectors.

 **实例:**       

 simple-selectors("div.myInput")       

 结果: div, .myInput       

 simple-selectors("div.myInput:before")       

 结果: div, .myInput, :before |


Sass Functions Sass Functions