Using LESS, how can I subtract values with "px" at the end of the variable. I have the following variable:
@bpMobile: 600px
What I want to do is subtract this by 1px
@media only screen and (max-width: @bpMobile - 1px ) { }
How can I achieve this with LESS?
What is the process of subtracting the mean of each variable from its variable called ? Mean Normalization — Correct. For different parameters of the hypothesis function we get the same hypothesis function.
If no number appears before the variable, then you can assume that the number is 1. So a = 1a and x = 1x. You add terms that have the same variables because they represent the same amounts. You don't try to add the terms with different variables.
Sorry for answering this late, but I had this very problem and it seems LESS is picky about the spacing. You also need ()
around your calculation.
This will not work:
@media screen and (max-width: (@widthSmall-2)) { }
However, this will (notice the space between the variable and the digit):
@media screen and (max-width: (@widthSmall - 2)) { }
You can always use the calc function
for this.
Syntax: calc(expression)
Eg:
abc { width:calc(100%-20px) }
Here are the list of browser that supports this function
EDIT 1:
you can use it in the following two ways:
LESS Input:
@bpMobile: 600px; max-width: calc(~'@{bpMobile} - 1px');
CSS Output:
max-width: calc(600px - 1px);
2nd Way: Less Input:
@bpMobile: 600px; max-width: calc(@bpMobile - 1px);
CSS Output :
max-width: calc(599px);
With the first option,the calc arguments are escaped in order to prevent them from being evaluated on compilation.The values will remain totally static until it's evaluated by the client.
With the second option, the calc value will be evaluated on compilation. And it would be the same as
max-width: @bpMobile - 1px;
which will result in
max-width: 599px;
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