I want to use Less mixin for borders in a project, but often I need to use different sides of border, not all.
I have written a simple mixin:
.border-all (@border; @border-type; @border-color) {
border-top: @border @border-type @border-color;
border-right: @border @border-type @border-color;
border-bottom: @border @border-type @border-color;
border-left: @border @border-type @border-color;
}
Is it possible for example to pass arguments only to border-top
and border-bottom
?
So:
.class {
.border-all (3px; double; @border-color);
}
Would output in:
.class {
border-top: 3px double #333;
border-bottom: 3px double #333;
}
Can I ignore passing parameters to different CSS properties in the mixin?
As it is, your current mixin cannot be modified to send parameters only to specific CSS properties. However, you can modify the mixin to be like the below snippet and pass the sides as arguments.
You just have to pass the required sides as the last argument to the mixin and only the corresponding properties would be generated in output CSS.