srcrustaceo
srcrustaceo

Reputation: 90

Concatenate multiple selectors in less

I'm trying to do this:

.a:concat(.b, .c, .d)

Expecting this result:

.a.b, .a.c, .a.d {}

Obviously this won't work since there isn't a function called concat in LESS. Can we achieve this with something else?

Thanks

Upvotes: 3

Views: 2389

Answers (1)

BoltClock
BoltClock

Reputation: 723438

That is not achieved with a pseudo-class, but with the & character in a nested rule:

.a {
  &.b, &.c, &.d {}
}

On an interesting note, there is in fact a pseudo-class being proposed for the upcoming Selectors standard, not as :concat() but as :matches(), with similar syntax. It's unimplemented outside of prefixes at the moment, but in the meantime, this is done a little differently with LESS.

Upvotes: 6

Related Questions