Skip to content
On this page

其他规则 @-rules

Stylus 对大多数 CSS @-规则提供基本支持,如 @viewport@page@host@supports 等。

@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

将编译为:

@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-rules

Stylus 支持任何尚未知的 @-规则,因此它对未来友好,任何 CSS 中的新 @-规则都可以使用 Stylus 的缩进语法编写并完美渲染:

@foo
  @bar
    width: 10px

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

    .baz
      height: 10px

将编译为:

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

Released under the MIT License.