Reputation: 1495
It is possible to convert a variable to a percentage? The below does not work I get calc(1675%) in the generated css
@hex-width : 67px;
margin: 1px calc(25% * @hex-width);
Upvotes: 2
Views: 3465
Reputation: 28437
What I thought you meant was this:
margin: 1px ~"calc(25% * @{hex-width})";
which would output
margin: 1px calc(25% * 67px);
Note that this isn't the same as using the float 0.25
! The above CSS will get a quarter of the parent's widthn abd multiply it with 67px.
To understand what's going on in LESS, see the documentation. First you override less's own calc-function: you want to echo calc() as is. However, you still want to use a variable in there, so you use String interpolation.
Upvotes: 0
Reputation: 33141
Just use decimal notation:
@hex-width : 67px;
margin: 1px calc(0.25 * @hex-width);
Upvotes: 7