4 file import sass
sass
The @import
rule generates css
put related files into a file comes in. This means that all styles are grouped into the same css
document, without having to initiate additional download request.
1 sass
file local file name begins with an underscore. Thus, sass
it will not this file output separately compiled at compile time css
, as this document only import. When you @import
when a local file, also can not write the full name of the file that underscore the beginning of the file name is omitted.
2 default variable values
!default
For variable, meaning: if this variable is declared assignment, and it values its statement, otherwise use the default values. And the css! In contrast important role
3. You can not use sass
the @import
direct import an original css
document, because sass
think you want to use css
native @import
. However, because sass
the syntax is fully compatible css
, so you can put the original css
file renamed the .scss
suffix, can be directly imported
4. Silent comment
body {
color: #333; // 这种注释内容不会出现在生成的css文件中
padding: 0; /* 这种注释内容会出现在生成的css文件中 */ }
When the comment appears in native css
place where, as in css
property or selector, sass
will not know how to generate the corresponding css
appropriate position in the file, then the notes have been erased.
If you need to import or SCSS Sass file, but do not want to compile it as CSS, just add an underscore in front of the filename, it will tell Sass do not compile these files, but do not need to add the import statement underlined.
For example, name the file _colors.scss, will not compile _colours.css file.
@import "colors";
The above example, the imported file is actually _colors.scss
Note that can not coexist with the same name as the file is not underline underline, the underline files will be ignored
sass imported (@import) and CSS rules are different, compile time will come @import of scss file merge only generate a CSS file. But if you import the file sass css file as @import 'reset.css', with the effect that the general CSS styles to import files, import css files are not merged into the compiled files, but rather in a way there is @import .
All sass import file can be ignored suffix .scss. Generally based file naming method _ beginning, as _mixin.scss. This file can not be imported at the time of writing the underscore, can be written @import "mixin"