将 SCSS 附加到 HTML 文档 [英] Attaching a SCSS to HTML docs

查看:64
本文介绍了将 SCSS 附加到 HTML 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是网页设计新手.我想学习如何将 SCSS 文件附加到 head 标签中的 HTML 文件:

Hello I am new to web design. I would like to learn how to attach an SCSS file to an HTML file in the head tag :

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

我试过这个,但没有看到结果.我想这就像 LESS 框架.还有一个问题:如果我想使用 SCSS,我是否应该将其编译为托管?

I tried this but did not see the result. I guess that it's like the LESS framework. And another question: If I want to use SCSS I should compile it to hosting or not?

推荐答案

您不能将 SASS/SCSS 文件附加"到 HTML 文档.

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

SASS/SCSS 是一个 CSS 预处理器,它运行在服务器上并编译为您的浏览器可以理解的 CSS 代码.

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

有一些客户端替代 SASS 可以使用 javascript 在浏览器中编译,例如 LESS 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.

就像在 HTML 文件中添加 2 行代码一样简单.

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>

这篇关于将 SCSS 附加到 HTML 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆