-
Book Overview & Buying
-
Table Of Contents
LESS WEB DEVELOPMENT COOKBOOK
By :
The built-in default() function plays a special role when leveraging mixins, especially mixin guards.
For this recipe, you will have to know something about parameterized mixins. You also need to be aware of what guards are and how to use them. You can find both in the Using mixin guards recipe in Chapter 6, Advanced Less Coding. You will also need a Less compiler, as discussed in Chapter 1, Getting to Grips with the Basics of Less.
Use the command-line lessc compiler to compile the following Less code:
.mixin(1) {
property: 1 * 2;
}
.mixin(2) {
property: 2 * 3;
}
.mixin(@a) when (default()) {
property: @a;
}
one {
.mixin(1);
}
five {
.mixin(5);
}The preceding Less code compiles into CSS, which looks like the following code:
one {
property: 2;
}
five {
property: 5;
}The default() function returns true for the situation if no other mixin matches. Note that the default() function can only be used in the parametric...
Change the font size
Change margin width
Change background colour