Is it possible to have a variable declared as !important
with LESS? Currently, I am getting a syntax error with the following.
For example:
@fontColor: #000000 !important;
p {
color: @fontColor;
}
Should render as:
p {
color: #000000 !important;
}
I know there is a way of escaping that is mentioned HERE, using the following:
@fontColor: #000000 ~'!important';
There was talk about implementing it as simple syntax quite a while ago like my first example, just not to sure if they ever did - https://github.com/less/less.js/issues/1401
Using Visual Studio 2013 (Update 4)
The accepted answer didn't work for me (I guess it was due to version, maybe).
What worked was the workaround mentioned in OP's question itself, which I didn't see at first.
In case it happens to someone else, just try the following:
// !important doesn't work
@fontColor: #000000 !important;
// !important works!
@fontColor: #000000 ~'!important';
Source
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