CSS预处理语言

CSS预处理语言

  Less,Sass,Stylus

安装

Less

  yarn add less

  运行命令 ./node_modules/.bin/lessc

嵌套规则

Less

#header {
  h1 {
    font-size: 26px;
    font-weight: bold;
  }
  p { font-size: 12px;
    a { text-decoration: none;
      &:hover { border-width: 1px }
    }
  }
}

变量

Less

@color: #4D926F;

#header {
  color: @color;
}
h2 {
  color: @color;
}

混合(mixin)

Less

.rounded-corners (@radius: 5px) {
  border-radius: @radius;
  -webkit-border-radius: @radius;
  -moz-border-radius: @radius;
}

#header {
  .rounded-corners;
}
#footer {
  .rounded-corners(10px);
}

extend

Less

.a{
    &:extend(.b);
    font-size: 12px;
}
.b{
    font-weight: bold;
}

猜你喜欢

转载自www.cnblogs.com/sonwrain/p/10492912.html
今日推荐