前端 - sass 如何import单条css选择器
PHP中文网
PHP中文网 2017-04-17 11:39:28
0
2
485

最近开始用sass,遇到了一个问题,看一下下面的代码

@import 'base.scss';

.btn {
  @extend reset-btn;
}

base.scss文件里面,有很多已经写好的选择器,但是,我只用到一个reset-btn,在这种情况下,我还是把整个base.scss文件里面所有的内容全部导了进来,就会有很多重复并且我用不到的代码,这种情况下,我该怎么解决呢?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
刘奇

If it is a written selector
`
.selector {
}
`
it will be used. No solution

So the imported files are best mixedin
or this kind of

`
%selector {
}
`

sass virtual class form

刘奇

sass will not have duplicate code. You will know after compiling it into css and taking a look. Although we may have defined many mixin, they will not be converted when they are not actually used in the project. into css, like here, the final generated css will only be reset-btn related to css

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template