<string> - 字符串的数据类型 - css 文本样式
在CSS中,是用来表示一串字符的数据类型,它被用在众多CSS属性中,例如
content
、font-family
、和quotes
。
示例
div:after{ content: "任意字符串\"String\""; } div{ /* \5b8b\4f53 = 宋体 */ font-family:'\5b8b\4f53'; }
浏览器支持
浏览器都支持 字符串的数据类型 |
使用规则
数据类型是由包含在英文双引号(")或英文单引号(')中的任意数量的Unicode字符组成。
- 大多数字符都可以写成字面量的形式,并且所有字符都可以写成以反斜线(\)开头的十六进制Unicode码点的形式。比如说:
\22
表示一个双引号,\27
表示一个单引号,\A9
表示版权声明符号(©)。 - 需要注意的是,在使用某些特殊字符时需要在前面加上反斜线来转义,包括但不限于在双引号字符串中使用双引号字符,在单引号字符串中使用单引号字符,以及反斜线字符,比如\\表示一个反斜线字符。
- 当你想换行的时候,必须使用像
\A
或者\00000A
这样的换行符。不过在你的代码中,可以通过在每行末尾增加一个反斜线(\)的方式来创建一个多行的字符串。 - 注意: CSS中不能使用像或者
—
这样的实体。
实例
/* Simple strings */ "This string is demarkated by double quotes." 'This string is demarkated by single quotes.' /* Character escaping */ "This is a string with \" an escaped double quote." "This string also has \22 an escaped double quote." 'This is a string with \' an escaped single quote.' 'This string also has \27 an escaped single quote.' "This is a string with \\ an escaped backslash." /* New line in a string */ "This string has a \Aline break in it." /* String spanning two lines of code (these two strings will have identical output) */ "A really long \ awesome string" "A really long awesome string"
内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)