Skip to content

字符转义

¥Char Escaping

Stylus 可让你转义字符。这有效地将它们转变为标识符,允许它们渲染为字面量。

¥Stylus lets you escape characters. This effectively turns them into identifiers, allowing them to be rendered as literals.

例如:

¥For example:

body
  padding 1 \+ 2
body
  padding 1 \+ 2

编译为:

¥Compiles to:

body {
  padding: 1 + 2;
}
body {
  padding: 1 + 2;
}

请注意,Stylus 要求在属性中使用时将 / 带括号:

¥Note that Stylus requires that / is parenthesized when used in a property:

body
  font 14px/1.4
  font (14px/1.4)
body
  font 14px/1.4
  font (14px/1.4)

产量:

¥yields:

body {
  font: 14px/1.4;
  font: 10px;
}
body {
  font: 14px/1.4;
  font: 10px;
}