4. NESTING (ANIDAMIENTO)
Te permite anidar dentro de un mismo padre todo el código ( nav, nav ul, nav ul li, ...)
También se puede anidar propiedades (border, font, ...)
Se usa & para acceder al padre &:hover
li {
font: {
family: serif;
weight: bold;
size: 1.2em;
}
a{
color: red;
&:hover{
color: green;
}
}
}
.scss
li {
font-family: serif;
font-weight: bold;
font-size: 1.2em;
}
li a{
color: red;
}
li a:hover{
color: green;
}
.css
5. VARIABLES
Variables begin with $ and are declared just like properties.
They can have any value that’s allowed for a CSS property, such
as colors, numbers (with units), or text.
$blue: #3bbfce;
$margin: 16px;
.content-navigation {
border-color: $blue;
color:
darken($blue, 9%);
}
.border {
padding: $margin / 2;
margin: $margin / 2;
border-color: $blue;
}
.scss
.content-navigation {
border-color: #3bbfce;
color: #2b9eab;
}
.border {
padding: 8px;
margin: 8px;
border-color: #3bbfce;
}
.css
13. Compilar sass
Colección de mixins CSS3 (no más prefijos!)
@include box-shadow(red 2px 2px 10px); }
-webkit-box-shadow: red 2px 2px 10px;
-moz-box-shadow: red 2px 2px 10px;
box-shadow: red 2px 2px 10px;
Helpers (clearfix, float, hacks)
Sprites
images/my-icons/new.png
images/my-icons/edit.png
images/my-icons/save.png
images/my-icons/delete.png
@import "my-icons/*.png";
@include all-my-icons-sprites;
14. Instalación y uso
Sass y compass son dos gemas de Ruby
gem install compass // INSTALAR COMPASS & SASS
compass create nombre_proyecto // CREA UN FICHERO config.rb
compass watch // Autocompila los .scss -> .css
15. config.rb
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "js"
output_style = :expanded
# You can select your preferred output style here:
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors.
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass