Skip to content
On this page

其他@规则

¥Other @-rules

Stylus 对大多数 CSS @ 规则的无括号语法提供基本支持,例如 @viewport@page@host@supports 等:

¥Stylus have a basic support for braceless syntax for most of the CSS @-rules, like @viewport, @page, @host, @supports and others:

@viewport
  color: #00f

@supports (display: flex)
  div
    display: flex

@page :blank
  @top-center
    content: none
@viewport
  color: #00f

@supports (display: flex)
  div
    display: flex

@page :blank
  @top-center
    content: none

将编译为

¥Would compile to

@viewport {
  color: #00f;
}
@supports (display: flex) {
  div {
    display: flex;
  }
}
@page :blank {
  @top-center {
    content: none;
  }
}
@viewport {
  color: #00f;
}
@supports (display: flex) {
  div {
    display: flex;
  }
}
@page :blank {
  @top-center {
    content: none;
  }
}

未知 at 规则

¥Unknown at-rules

Stylus 支持任何未知的 @ 规则,因此它是面向未来的,因为 CSS 中的任何新的 at 规则都可以用基于缩进的 Stylus 语法编写,并且可以完美渲染:

¥Stylus supports any yet unknown @-rules, so it is future-friendly, as any new at-rules in CSS could be written in indentation-based syntax of Stylus and would be rendered perfectly:

@foo
  @bar
    width: 10px

    .baz
      height: 10px
@foo
  @bar
    width: 10px

    .baz
      height: 10px

将被编译为

¥Would be compiled to

@foo {
  @bar {
    width: 10px;
    .baz {
      height: 10px;
    }
  }
}
@foo {
  @bar {
    width: 10px;
    .baz {
      height: 10px;
    }
  }
}