6

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

4

1 回答 1

11

我不确定你是否可以这样做,但这也有效。我假设您只想编写一次长伪类。

input[type=text], input[type=email], input[type=password], textarea {
   // styles for normal

   &:focus {
      // styles for focus
   }

   &:hover {

   }
}
于 2013-07-15T19:55:36.890 回答