<
Neerav Mehta
Founder & CEO
Variables: You can define variables like: $blue: #3bbfce; $margin: 16px; You can use it where you want to use the same value in class of css. There are also many functions available to define variable values. All available functions are listed over here: http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html
Nesting: This one is very interesting. It is used to avoid repetition. We can use it like this:
ul {
float:left;
margin-left:10px;
li {
float:left;
padding-left:5px;
img {
border: none;
}
}
}
@mixin left($dist) {
float: left;
margin-left: $dist;
padding-left: $dist;
}
ul{
@include left(10px);
li{
float:left;
padding-left:5px;
img {
border:none;
}
}
}
.first{color:black; font-weight:bold;}
In scss we can write this as,
li.first{@extend .first; padding-left:0px; }
```
#### Where do you need to write it?
Create a directory **"sass"** in your theme directory. Put all your scss files in it. You don’t need to write a css file. You can write a scss file and generate a css file from it.
#### How to generate css from scss?
- Download ruby installer from this page: [http://rubyinstaller.org/downloads/](http://rubyinstaller.org/downloads/)
- After installing the installer package, open your command prompt.
- Write the command **"gem install compass"**
- After completing installation, use command **"compass version"** to check if properly installed
- Now go to your project theme directory and execute command **"compass init"**. This will generate config.rb file in your theme directory, which will have all the basic information that you will need to generate css from scss
- http_path = "/"
- css_dir = "css"
- sass_dir = "sass"
- images_dir = "images"
- javascripts_dir = "js"
- Now execute “compass watch”. This will convert all your scss file to css files.Also if there is any error it will show you.
- Once completed, press “ctrl + c” to finish.
<Author name="Neerav Mehta" isShort={false} />
Let’s get you started!