scss自动生成margin padding边距

// 自动生成一个margin padding的css函数 使用ml-20 代表margin-leftt: 20px
$directions:('t': 'top', 'b': 'bottom', 'l': 'left', 'r': 'right');
$dimensions:('p': 'padding', 'm': 'margin');
//获取padding margin间隔
@each $dim in $dimensions {
  //循环四个方向
  @each $dir in $directions {
    @for $i from 1 through 50 {
      $size: $i*1;
      .#{nth($dim,1)}#{nth($dir,1)}-#{$size} {
        #{nth($dim,2)}-#{nth($dir,2)}: #{$size}px;
      }
    }
  }
}

  

posted @ 2024-06-05 15:21  惠鹏曦  阅读(2)  评论(0编辑  收藏  举报