W
W
winbackgo2014-02-13 19:53:17
Less
winbackgo, 2014-02-13 19:53:17

Less: how to implement multiple selectors in a variable?

We have:

select, textarea, input[type="text"], input[type="password"] {
   color: #000;
 }

.error {
  select, textarea, input[type="text"], input[type="password"] {
    color: red;
  }
}

I want to:
@input-selector: ~'select, textarea, input[type="text"], input[type="password"]';

@{input-selector} {
   color: #000;
 }

.error {
  @{input-selector} {
    color: red;
  }
}

But the result is not happy:
select, textarea, input[type="text"], input[type="password"] {
  color: #000;
}
.error select, textarea, input[type="text"], input[type="password"] {
  color: red;
}

Is it possible to implement this in less? Those. store a list of selectors in one place.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SerDIDG, 2014-02-19
@SerDIDG

I solved it myself like this:

#bundle {
    .input {
        color: #000;
        
        .error & {
            color: red;
        }
    }
}

select, textarea, input[type="text"], input[type="password"] {
    #bundle > .input;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question