你可以导入一个css文件并使用sass来迭代每个规则并附加!重要吗?

问题描述 投票:0回答:1

你能拿一个文件并用 sass 稍微更新每个 css 规则吗?例如

样式.scss

  .bold {
    font-weight: 600
  }
  .bolder {
    font-weight: 800
  }
// ...

样式重要.scss

// Here I want to import and produce the following:

  .bold-important {
    font-weight: 600 !important;
  }
  .bolder-important {
    font-weight: 800 !important;
  }

sass可以产生这个吗?另一个 css 预处理器可以完成这个任务吗?

css sass stylesheet
1个回答
0
投票

抱歉,Sass 无法做到这一点。您能做的最好的事情就是像这样在数组中循环:

@each $animal in puma, sea-slug, egret, salamander {
    .#{$animal}-icon {
      background-image: url('/images/#{$animal}.png');
    }
}

但这并不能解决你的问题

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.