成长(18/2000)——SASS2

2021-06-24  本文已影响0人  Kiki_Q

@media

@media screen {
  .sidebar {
    @media (orientation: landscape) {
      width: 500px;
    }
  }
}
编译为
@media screen and (orientation: landscape) {
  .sidebar {
    width: 500px;
 } 
}

!optional

@at-root ( @at-root (without: ...) and @at-root (with: ...))

.parent {
  ...
  @at-root .child { ... }
}
编译后
.parent { ... }
.child { ... }

@debug @warn @error

@debug 10em + 12em;
编译为
Line 1 DEBUG: 22em

函数指令

$grid-width: 40px;
$gutter-width: 10px;

@function grid-width($n) {
  @return $n * $grid-width + ($n - 1) * $gutter-width;
}

#sidebar { width: grid-width(5); }
编译后
#sidebar {
  width: 240px;
 }

拓展

 "scripts": {
    "dev:sass": "node-sass --watch --recursive -- output css --source-map 
      true --source-map-content"
  },
上一篇下一篇

猜你喜欢

热点阅读