When I use this calc(100% + 20px)
directly in Chromes and Firefox' Inspector it works fine and as shown.
However when I insert it into my less file it gets converted to 120%
. What am I doing wrong?
When I use this calc(100% + 20px)
directly in Chromes and Firefox' Inspector it works fine and as shown.
However when I insert it into my less file it gets converted to 120%
. What am I doing wrong?
Less will try to process all maths including 100% + 20px
.
You could either set Strict Math on:
lessc -sm=on
lessc --strict-math=on
Or use a tilde-quote ~"100% + 20px"
in order to prevent the statement from being processed by Less.
For instance:
.class {
padding-left: calc(~"100% + 20px");
}
.class {
padding-left: ~"calc(100% + 50px)";
}
if you have some variable defined for example
@toolbar-height: 50px;
this can be written as below
.class {
padding-left: ~"calc(100% + @{toolbar-height})";
}
this will not create any issue when you convert your CSS file into less