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 字符串从 1 开始。字符串中的第一个字符位于索引 1 处,而不是 0。

下表列出了 Sass 中的所有字符串函数

函数 描述 & 示例
quote(string) string 添加引号,并返回结果。

示例
quote(Hello world!)
结果: "Hello world!"
str-index(string, substring) 返回 substringstring 中首次出现的索引。

示例
str-index("Hello world!", "H")
结果: 1
str-insert(string, insert, index) 返回在指定 index 位置插入 insertstring

示例
str-insert("Hello world!", " wonderful", 6)
结果: "Hello wonderful world!"
str-length(string) 返回 string 的长度(以字符计)。

示例
str-length("Hello world!")
结果: 12
str-slice(string, start, end) string 中提取字符;从 start 开始,到 end 结束,并返回切片。

示例
str-slice("Hello world!", 2, 5)
结果: "ello"
to-lower-case(string) 返回 string 的副本,转换为小写。

示例
to-lower-case("Hello World!")
结果: "hello world!"
to-upper-case(string) 返回 string 的副本,转换为大写。

示例
to-upper-case("Hello World!")
结果: "HELLO WORLD!"
unique-id() 返回一个唯一的随机生成的无引号字符串(保证在当前 sass 会话中是唯一的)。

示例
unique-id()
结果: tyghefnsv
unquote(string) 删除 string 周围的引号(如果有),并返回结果。

示例
unquote("Hello world!")
结果: Hello world!

×

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.