DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use Sass

05.04.2009
| 4378 views |
  • submit to reddit
        Sass is a meta-language on top of CSS. 

Installation: Sass is part of Haml, which is available via git.  
gem install haml

Sass can be used with Ruby, Ruby on Rails or as a command-line tool.
To run Sass from the command line
sass input.sass output.css

Sample Usage (with variables)
// constants
!main_color = blue
!site_background = white 

body
  :color = !main_color
  :font 
    :family verdana, arial, sans-serif
    :size 12px

Sass can calculate 
!color2 = !main_color*0.33 + !site_background*0.67 
!color3 = !main_color*0.67 + !site_background*0.33 

#box
  :color = !color2
  :background_color = !color3

Remarks:
- Sass bzw. Haml Homepage: http://haml.hamptoncatlin.com/
- Sass and CSS cannot be mixed. Existing CSS has to be translated to Sass first. The commandline tool "css2sass" can help.