跳至内容
本页内容

其他 @ 规则

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 规则

Stylus 支持任何尚未了解的 @ 规则,因此它对未来友好,因为 CSS 中的任何新 at 规则都可以用 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;
    }
  }
}