SASS常用方法

cnpm install --save-dev sass-loader  
//sass-loader依赖于node-sass 
cnpm install --save-dev node-sass
//实现BEM的模式
.block { color: red; 
@at-root #{&}-green{ 
    color: green; 
} 

//继承
.row {
  @extend .fn-clearfix;
}

//循环
@for $i from 1 to 12{
  .t#{$i} {
    top: ($lh*$i);
  }
}

/*栅格*/
$gridColumns: 12 !default;
$gridGutter: 20px !default;
.row {
  margin-right: -$gridGutter / 2;
  margin-left: -$gridGutter / 2;
  @extend .fn-clearfix;
}
%col{
  float:left; min-height: 1px;padding-left:$gridGutter / 2; padding-right:$gridGutter / 2;
}

@for $i from 1 through  12 {//to 不包含12
  .col-md-#{$i} {
    @extend %col;
    float: left;
    width: $i/$gridColumns*100%;
  }
}
$file-types:doc pdf txt xls rar mp4;
@each $type in $file-types{
    .#{$type}{
        background-image:  url(/static/images/#{$type}.png);
    }
}
posted @ 2019-01-11 08:34  conglvse  阅读(645)  评论(0编辑  收藏  举报