Sass是一個具有語法改進功能的CSS預處理器。高級語法中的樣式表由程序處理,並轉換爲常規的CSS樣式表。但是,它們本身不會擴展CSS標準。
這樣做的主要原因是添加了CSS痛苦地缺乏的功能(如變量)。
重新SCSS和薩斯之間的差別,在Sass home page文本應該回答的問題是:
Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.
Sass has two syntaxes. The new main syntax (as of Sass 3) is known as 「SCSS」 (for 「Sassy CSS」), and is a superset of CSS3’s syntax. This means that every valid CSS3 stylesheet is valid SCSS as well. SCSS files use the extension .scss.
The second, older syntax is known as the indented syntax (or just 「Sass」). Inspired by Haml’s terseness, it’s intended for people who prefer conciseness over similarity to CSS. Instead of brackets and semicolons, it uses the indentation of lines to specify blocks. Although no longer the primary syntax, the indented syntax will continue to be supported. Files in the indented syntax use the extension .sass.
然而,這一切只能與薩斯預編譯器最終創建CSS。它不是CSS標準本身的擴展。
是的,我之前做過同樣的事情。我只是想知道這是否意味着'sass'命令和'scss'命令在引擎蓋下是一樣的? – houhr
@houhr由於SCSS是CSS3的超集,而SASS不是。我相信這些命令在引擎蓋下不一樣,即使它們應該輸出相同的CSS。 – sargas