Less的!important关键字

来源:互联网 发布:国际象棋和围棋 知乎 编辑:程序博客网 时间:2024/05/18 20:47

Less的!important关键字

在调用 mixin 时,如果在后面追加 !important 关键字,就可以将 mixin 里面的所有属性都标记为 !important。如,以下Less代码:

  1. .mixin() {
  2.   color: #900;
  3.   background: #F7BE81;
  4. }
  5. h2 {
  6.   .mixin() !important;
  7. }

编译后的CSS代码为:

  1. h2 {
  2.   color: #900 !important;
  3.   background: #F7BE81 !important;
  4. }