3. SASS CSS
Ruby engine compiler for CSS
Extending the benefits of CSS by allowing nested rules, variables,
mixins, selector inheritance, and more.
http://sass-lang.com/
Other equivalent processors:
Javascript: LESS - http://lesscss.org/
CSS Authoring Framework: COMPASS - http://compass-
style.org/
4. Pros & Cons of SASS
Pros Cons
•Uniform CSS •Reliance of a compiler
•Abstraction of commonly used •Knowledge of Ruby language is
CSS - mixins helpful
•Ability to create functions •All or nothing
•Variables •Disconnect between CSS and
•Nesting SASS CSS in dev consoles
5. Variables
In CSS we widely use common values for different element styles.
For example, we use colors, width, height, etc... throughout our CSS styles.
With variables, these common values can be declared once and re-used throughout the
stylesheets.
Example:
$tableColor: #F3F1EB;
$tableBorderColor: #EFEFEF;
@mixin sortBg {
background:$tableColor url('../img/bg.gif') no-repeat right center;
&:hover {
background-color: darken($tableColor, 25%);
}
}
6. Mixins
Mixins are a very potent asset of SASS.
With mixins, the most commonly used CSS can be abstracted to a mixin and included as
needed.
Example:
@mixin handCursor {
cursor: hand;
cursor: pointer;
}
7. Mixins - Advanced
Mixins can become very advanced and can contain logic .
Example - setting Linear Gradients - http://kiano.sh/IjEpZm
9. SASS CSS Boilerplate
Leveraging the CSS from HTML5 boilerplate, converted it to SASS equivalent.
Divide the style.css file into the following modular sections:
normalize.scss - http://kiano.sh/IBIrzU
helper.scss
style.scss
functions
partials
10. Further reading
SASS CSS - www.sass-lang.com
SASS Cocktails - collections of SASS mixins and functions - http://kiano.sh/J89RI9
SASS CSS Boilerplate - http://kiano.sh/IlZt2b
Thoughtbot/bourbon - Series of mixins and functions - http://kiano.sh/IQNOZ6
How to write a well structured CSS - http://kiano.sh/Inxxym
Feel free to tweet me a questions, twitter: @kianoshp
blog: http://innovatorylife.com