Meetup
Lead Frontend developer @
Thomas Roux
+
@spartdev
Born in ruby on rails community
Designed by Hampton Catlin
Maintained by Nathan Weizenbaum et Chris Eppstein
Write your sass script
Preprocess
Generated css
Install Ruby
Install Sass Ruby Gem
+
sass --watch <source>:<destination>
.main
font-size: 10px
margin: 5px
text-align: center
label
color: green.main {
font-size: 10px;
margin: 5px;
text-align: center;
}
label {
color: green;
}Variables allow you to assign a value and reuse them anywhere !
Can assign boolean, color, text, string …
// Assign Variables
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
// Use it
body {
font: 100% $font-stack;
color: $primary-color;
}body {
font: 100% Helvetica, sans-serif;
color: #333;
}Sass
Css
Compile phase
.nav.tabbed-navigation {...}
.nav.tabbed-navigation a {...}
.nav.tabbed-navigation a span {...}If .nav class change you will have to rewrite the three CSS selectors...
.nav {
margin: 10px;
.tabbed-navigation {
padding: 5px;
width: 20%;
a {
font-size: 1,8rem;
color: red;
span {
color: green;
}
}
}
}
Clear hierarchy
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.myClassname {
@include border-radius(10px);
}.myClassname {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}Sass
Css
Compile phase
function shade($color + $percent) {
@return mix(#000, $color, $percent);
}
body {
background: shade(grey, 50%);
}
Native Functions...
body {
font-size: 1px + 10px +3px; // 14px
background-color: #777 + #888 // white
}
.myDivClass {
height: (1000px/2) // 500px
}
$var: full;
.mySecondDiv {
@if $var === full {
width: 100%;
} @else {
width: 50%;
}
}Load different modules to make css !
@import '_header';
@import '_page';
@import '_sidebar';
You can share css declaration with @extend
.error {
color: red;
}
.serious-error {
@extend .error;
font-weight: bold;
}
.error, .serious-error {
color: red;
}
.serious-error {
font-weight: bold;
}
Sass
Css
Compile phase