Using Code Block for Pseudo-Classes in LESS
Let's make a function that will set the link styles in the hover
state.
Let this function take a block of code as a parameter:
.hover(@code) {
}
Let's print the passed block of code inside the hover
state:
.hover(@code) {
&:hover {
@code();
}
}
Let's use our function inside the link:
a {
color: red;
.hover({
color: blue;
text-decoration: none;
});
}
Compilation result:
a {
color: red;
}
a:hover {
color: blue;
text-decoration: none;
}
Make a similar function that will set styles for the input in the focus
state.