4

I have a LESS variable: @columns: 12

I would like to pass this variable into a CSS class name ideally as: .one-{@columns}-inner {}

Is it possible?

3
  • What do you mean it doesn't parse correctly ? How are you compiling the files ? Are you getting an error ? Commented Jun 9, 2015 at 11:51
  • .one-{@columns}-inner {} - This won't work because there is an error and the @ should be present outside the braces but the one in the answer should work unless you are using a very outdated compiler version. Commented Jun 9, 2015 at 13:30
  • This had been answered nicely by pinturic. Thank you! Commented Jun 10, 2015 at 8:45

1 Answer 1

4

Simply you can do it this way:

// Using variables
.one-@{columns}-inner {
    color: black;
}
Sign up to request clarification or add additional context in comments.

4 Comments

I have tried this and that doesn't parse correctly.
It works but unfortunately I am parsing via less.js. I guess that is the issue I am having.
It depends on the compiler version (I think it is from version 1.3 and upgraded in 1.3.1). I have tested it here and it is working: winless.org/online-less-compiler. Which version do you have ?
1.1.3 ... but I have tested the solution with a grunt compiler and all was fine. Cheers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.