Can we try changing our theme quickly? I think blue buttons will be more engaging!
Hm.. It's not that quick. Come back in 30 min?
Ah it's ugly! an we try lighter blue and compare it to this orange and green too?
Having multiple CSS files is essential for maintainability and collaboration
But @import sucks (additional HTTP requests)
We need to use a build tool for concatenation.
... but maybe it can do more than just that?
This is what CSS preprocessor do :)
A scripting language that extends CSS and get compiled into regular CSS syntax.
Less, Sass and Stylus support them all
They don't enhance CSS, but improve your
development workflow
They are actually constants (and it's fine)
$my_blue: #4e6cb0; // Sass @my_blue: #4e6cb0; // Less my_blue = #4e6cb0; // Stylus $primary_color: $my_blue; h1 { color: $primary_color; }
Variable are not just for colors!
$fonts: Helvatica, Arial, sans-serif; $images_path: "../img"; $font_size: 1.5em; $margin: 20px; $width: 100%;
Math and colors options
width: 25px * 4 + 100px / 2 - 50px; // = 100px color: #990033 + #666666; // = #FF66CC
Color functions
$light_blue: lighten($my_blue, 20%);
$flashy_blue: saturate($my_blue, 50%);
@mixin border-radius($radius: 10px) { -webkit-border-radius: $radius; -moz-border-radius: $radius; border-radius: $radius; } .button { @include border-radius(4px); }
.pop { .pop-btn{ } } //======= OUTPUT =======// .pop { } .pop .pop-btn { }
.link { &:hover{ } } //======= OUTPUT =======// .link { } .link:hover { }
@import "colors"; @import "typography"; @import "layout"
#main{color:#fff;background-color:#000}#main p{width: 10em}.huge{font-size:10em;font-weight:bold;text-decoration:underline}
@import "compass/css3/border-radius"; .button { @include border-radius(10px); }
> gem install sass
> sass --watch
> gem install compass
> compass create
> compass --watch