简体   繁体   中英

How to use sass (scss) compared to css

So to start off, let me introduce myself as a complete beginner. I want to get startet with scss, but I'm confused about how it works in regards to my css file. After having set of sass, and compiled my css to sass, should I then link my html to the sass file instead of to the css? And would I then delete my css file from the FTP and instead upload the sass file?

Thanks, Jonas the newbie.

scss or sass files are an improved syntax to write CSS, but remember that browsers can only understand CSS files. You can write a file with the sass or scss syntax, then compile it to a css file, and link this css file in your html file. So no, you will never upload anything else than the css file to your FTP.

Nope. Scss file is just for you to write code in more convenient style. You should link html to main css file. And put on server only css file.

Good practice is break scss in small pieces and import to one scss file, which is transpiled to css.

F. ex. my main.scss file (transpiling to main.css linked to html site) looks like this:

// Layout
@import '_layout/_navbar';
@import '_layout/_main';
@import '_layout/_footer';
@import '_layout/_header';
@import '_layout/_blog';
@import '_layout/_aside';

// Components (you can replace the below ones to bootstrap or other framework's files just with components)
@import '_components/_blockquote';
....

This is the biggest asset of scss.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM