将 Sass/SCSS 附加到 HTML 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19215517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Attaching a Sass/SCSS to HTML docs
提问by Cato Cato
Hello am new to web design and I have many questions about it. I want to learn how to attach a SASS or SCSS file to an HTML file in the head tag :
你好,我是网页设计的新手,我有很多关于它的问题。我想学习如何将 SASS 或 SCSS 文件附加到 head 标签中的 HTML 文件:
<link href="example" rel="stylesheet/sass" type="text/css">
<link href="example" rel="stylesheet/scss" type="text/css">
I tried this but did not see the result. I guess that it's like the LESS framework. And another question: If I want use SASS or SCSS I should compile it to hosting or not?
我试过这个,但没有看到结果。我想这就像 LESS 框架。还有一个问题:如果我想使用 SASS 或 SCSS,我应该将其编译为托管吗?
采纳答案by Sam Hunter
You can not "attach" a SASS/SCSS file to an HTML document.
您不能将 SASS/SCSS 文件“附加”到 HTML 文档。
SASS/SCSS is a CSS preprocessor that runs on the server and compiles to CSS code that your browser understands.
SASS/SCSS 是一个 CSS 预处理器,它在服务器上运行并编译成浏览器可以理解的 CSS 代码。
There are client-side alternatives to SASS that can be compiled in the browser using javascript such as LESS CSS, though I advise you compile to CSS for production use.
有一些客户端替代 SASS 可以使用 javascript 在浏览器中编译,例如LESS CSS,但我建议您编译为 CSS 以供生产使用。
It's as simple as adding 2 lines of code to your HTML file.
就像在 HTML 文件中添加 2 行代码一样简单。
<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="less.js" type="text/javascript"></script>