将 SCSS 附加到 HTML 文档

你好,我是新的网页设计。我想学习如何附加一个 SCSS 文件到 HTML 文件的头标记:

<link href="example" rel="stylesheet/scss" type="text/css">

我试过了,但没有看到结果。我想这就像是一个更少的框架。还有一个问题: 如果我想使用 SCSS,我应该编译它到托管还是不?

323053 次浏览

You can not "attach" a SASS/SCSS file to an HTML document.

SASS/SCSS is a CSS preprocessor that runs on the server and compiles to CSS code that your browser understands.

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.

It's as simple as adding 2 lines of code to your HTML file.

<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="less.js" type="text/javascript"></script>