Say I have a group of elements that I want to apply pseudo classes to, is there a way to define muliple elements in a variable and then apply a pseudo class to all of them at once? Like so:
@inputs: input[type=text], input[type=email], input[type=password], textarea;
@inputs {
//some styles;
}
@inputs:focus{
//some focus-specific styles;
}
Apologies if this is too obvious, I am reletively new to LESS
You can use only one pseudo-element in a selector. It must appear after the simple selectors in the statement. Note: As a rule, double colons ( :: ) should be used instead of a single colon ( : ).
A pseudo-class is used to define a special state of an element. For example, it can be used to: Style an element when a user mouses over it. Style visited and unvisited links differently.
Combining pseudo classes with CSS classesIt is possible to combine pseudo classes and regular CSS classes. This combination lets you style elements that have specific classes and also react to certain external factors.
If you're talking about pseudo-classes, then yes, you can combine them in any order.
I am not sure if you can do that but this works too. I am assuming you just want to write the long pseudo class once.
input[type=text], input[type=email], input[type=password], textarea {
// styles for normal
&:focus {
// styles for focus
}
&:hover {
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With