mixins
los mixins son porciones de codigo reutilizables equivalente a una funcion pero son para definir valores
scss
@mixin theme($theme: DarkGray) {
background: $theme;
box-shadow: 0 0 1px rgba($theme, .25);
color: #fff;
}
.info {
@include theme;
}
.alert {
@include theme($theme: DarkRed);
}
.success {
@include theme($theme: DarkGreen);
}
@mixin theme($theme: DarkGray) {
background: $theme;
box-shadow: 0 0 1px rgba($theme, .25);
color: #fff;
}
.info {
@include theme;
}
.alert {
@include theme($theme: DarkRed);
}
.success {
@include theme($theme: DarkGreen);
}
sass
@mixin theme($theme: DarkGray)
background: $theme
box-shadow: 0 0 1px rgba($theme, .25)
color: #fff
.info
@include theme
.alert
@include theme($theme: DarkRed)
.success
@include theme($theme: DarkGreen)
@mixin theme($theme: DarkGray)
background: $theme
box-shadow: 0 0 1px rgba($theme, .25)
color: #fff
.info
@include theme
.alert
@include theme($theme: DarkRed)
.success
@include theme($theme: DarkGreen)
less
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
.bordered();
}
.post a {
color: red;
.bordered();
}
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
.bordered();
}
.post a {
color: red;
.bordered();
}
dato curioso en less si no asignamos el mixin se comporta como un selector de clase
stylus
border-radius(n)
-webkit-border-radius n
-moz-border-radius n
border-radius n
form input[type=button]
border-radius(5px)
border-radius(n)
-webkit-border-radius n
-moz-border-radius n
border-radius n
form input[type=button]
border-radius(5px)