Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Sass 选择器函数


Sass 选择器函数

选择器函数用于检查和操作选择器。

下表列出了 Sass 中所有选择器函数

函数 描述和示例
is-superselector(super, sub) 检查super选择器是否匹配sub匹配的所有元素。

示例
is-superselector("div", "div.myInput")
结果:true
is-superselector("div.myInput", "div")
结果:false
is-superselector("div", "div")
结果:true
selector-append(selectors) 将第二个(以及第三个/第四个等)选择器附加到第一个选择器。

示例
selector-append("div", ".myInput")
结果:div.myInput
selector-append(".warning", "__a")
结果:.warning__a
selector-extend(selector, extendee, extender)  
selector-nest(selectors) 根据提供的列表返回一个包含嵌套 CSS 选择器列表的新选择器。

示例
selector-nest("ul", "li")
结果:ul li
selector-nest(".warning", "alert", "div")
结果:.warning div, alert div
selector-parse(selector) 使用与父选择器相同的格式返回selector中包含的字符串列表。

示例:
selector-parse("h1 .myInput .warning")
结果:('h1' '.myInput' '.warning')
selector-replace(selector, original, replacement) 返回一个新选择器,其中replacement中指定的选择器替换了original中指定的选择器。

示例
selector-replace("p.warning", "p", "div")
结果:div.warning
selector-unify(selector1, selector2) 返回一个新选择器,该选择器仅匹配selector1selector2都匹配的元素。

示例
selector-unify("myInput", ".disabled")
结果:myInput.disabled
selector-unify("p", "h1")
结果:null
simple-selectors(selectors) 返回selectors中各个选择器的列表。

示例
simple-selectors("div.myInput")
结果:div, .myInput
simple-selectors("div.myInput:before")
结果:div, .myInput, :before

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.