Here is what I would like to do. Not sure if its possible with LESS CSS, but I have a feeling I just can't find the syntax.
@height : 50px;
@wrap : 25px;
@bgsize : ((@wrap/@height)*100)+'%';
So that @bgsize == 50%
, everything I've tried has cause the script to fail.
Create a stylesheet with . less extension and link it in your document using the rel="stylesheet/less" attribute. You are all set and can compose styles within the . less .
Less (which stands for Leaner Style Sheets) is a backwards-compatible language extension for CSS. This is the official documentation for Less, the language and Less. js, the JavaScript tool that converts your Less styles to CSS styles. Because Less looks just like CSS, learning it is a breeze.
The Excel MIN function returns the smallest numeric value in the data provided.
Actually, a more elegant way of doing this is just using the percentage()
function which is built into LESS.
@height : 50px;
@wrap : 25px;
@bgsize : percentage(@wrap/@height);
// @bgsize == 50%
Perhaps this was added in a newer version of LESS.
AFAIK, expression result will always use the same units as its operands; appending percentage sign to the end will yield something like '50px %' at best or fail altogether.
That said, you can do the following (which is not very elegant, but works):
@height-in-pixels: 50;
@wrap-in-pixels: 25;
@bgsize: @wrap-in-pixels / @height-in-pixels * 100%;
@height: @height-in-pixels + 'px';
@wrap: @wrap-in-pixels + 'px';
You can always avoid the last two lines and "-in-pixels" indirection if you specify units in the actual property definition, too.
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