Sass Study Note

Sass is written by Ruby. So if you want to use Sass, you need to have Ruby first. Here we list steps to install Sass on Mac.

brew install ruby
ruby -v
sudo gem install sass
sass -v

Here we finish the installation of Sass. If you want to update Sass, you just need to run:

gem update sass

And if you want to uninstall Sass, you can use :

gen uninstall sass

How to use it:

you can create a test.scss file and run command like this:

sass --watch test.scss:test.css

And then you will get your css file.

Sass can be separated to two versions: one is sass, the other is scss. Sass grammar is different with css grammar rule. Sass requests: no ; and {}. But Scss is the same with css. But both of them require to use tab to control indentation.

In fact, when we do web development, we still need to use css file to callback, not Sass. Sass is only pre-compile. We need to use compile commands to transfer from sass to css. The command we just mentioned in above. For multiple files, we can use this:

sass sass/:css/

If you don’t want re-compile when you change the file, you just need to add –watch to start monitor feature which will help you to automatically compile when it is changed.

How to write down scss, there are several important concepts:

@mixin  @include : it is like function and recall function

@extend  : inherit

%placeholder   @extend

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s