Is there any efficient way to write this code with less.js:
- I've got already 3 variables colors : @vert, @violet and @orange
li {
&:nth-child(1) {
background: @vert;
&:hover,
&.open {
>.dropdown-menu li {
background: @vert;
}
}
}
&:nth-child(2) {
background: @violet;
&:hover,
&.open {
>.dropdown-menu li {
background: @violet;
}
}
}
&:nth-child(3) {
background: @orange;
&:hover,
&.open {
>.dropdown-menu li {
background: @orange;
}
}
}
}
I thought of a mixin, but I'm not writing well: Any help please ?
.colored-menu(@number, @color) {
&:nth-child(@number) {
background: @color;
&:hover,
&.open {
>.dropdown-menu li {
background: @color;
}
}
}
}
and calling it like this:
.colored-menu(1,@vert);
.colored-menu(2,@violet);
.colored-menu(3,@orange);