I'm trying to use LESS css to do the following:
width: ((480/1366)*100)+'%';
The problem though is that the output becomes:
width: 35.13909224011713 '%';
How do I make it workable? ie.:
width: 35.13909224011713%;
I'm trying to use LESS css to do the following:
width: ((480/1366)*100)+'%';
The problem though is that the output becomes:
width: 35.13909224011713 '%';
How do I make it workable? ie.:
width: 35.13909224011713%;
It is possible to use string interpolation:
That will output
Additionally, if you want it to be rounded, you can use
round()
.For some reason the least verbose and most obvious method is sort of missing here (it's in Richard Testani answer actually but there it's hindered with further code leading to a wrong direction). So... The answer to original:
is as simple as:
Speaking of
percentage
:Even though this question is quite old, I want to add a few more examples about adding. Less will set your units to whatever is being operated on.
will output 30px
will output 10%
So with units you dont need to concatenate the unit measurement.
I have found that adding 0 helps when you dont know what the unit value might be.
The above class will have a width of 20%. If we added with px, it would be 20px.