Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Preprocesador CSS
Ejemplo de SASS
/* Definir variables */
$bgcolor: lightblue;
$textcolor: darkblue;
$fontsize: 18px;
/* Usar variables */
body {
background-color: $bgcolor;
color: $textcolor;
font-size: $fontsize;
}
Características
#container {
width: $myWidth;
}
Ámbito de variables
$myColor: red; h1 {
color: green;
h1 { }
$myColor: green;
color: $myColor; p{
} color: red;
}
p{
color: $myColor;
}
//main.scss
@import "colors";
body {
font-family: Helvetica, sans-serif;
font-size: 18px;
color: $myBlue;
}
Mixins
@mixin important-text { .danger {
color: red; color: red;
font-size: 25px; font-size: 25px;
font-weight: bold; font-weight: bold;
border: 1px solid blue; border: 1px solid blue;
} background-color: green;
}
.danger {
@include important-text;
background-color: green;
}
Mixins con variables y valores por defecto
//Mixin con dos argumentos .myArticle {
@mixin bordered($color, $width) { border: 1px solid blue;
border: $width solid $color; }
}
.myNotes {
.myArticle { border: 2px solid red;
@include bordered(blue, 1px); } }
.myNotes {
@include bordered(red, 2px); }
.button-report { .button-report {
@extend .button-basic; background-color: red;
background-color: red; }
}
.button-submit {
.button-submit { background-color: green;
@extend .button-basic; color: white;
background-color: green; }
color: white;
}