CSS3 calc() function doesn't work with LESS
See original GitHub issueI know it’s been reported already but bugs were closed due to insufficient information.
I have the following CSS code:
#id1 {
position: fixed;
left: 0; top: 0;
width: 130px;
}
#id2 {
position: fixed;
right: 0; top: 0;
width: calc(100% - 130px);
}
I wanted to transform it into LESS using 130px
as a parameter but calc gets internpreted by LESS and this:
@id1width: 130px
#id1 {
position: fixed;
left: 0; top: 0;
width: @id1width;
}
#id2 {
position: fixed;
right: 0; top: 0;
width: calc(100% - @id1width);
}
makes the last but one line transformed to width: calc(-30%);
which is clearly not what’s desired. I tried using width: ~"calc(100% - @id1width)";
but it makes @id1width
not interpreted.
I think LESS shouldn’t use things reserved by CSS3 for its internal use…
Issue Analytics
- State:
- Created 11 years ago
- Reactions:19
- Comments:51 (21 by maintainers)
Top Results From Across the Web
Disable LESS-CSS Overwriting calc() - Stack Overflow
This works as Less concatenates values (the escaped strings and math ... note that Strict Math is applied globally, not only inside calc()...
Read more >CSS3 calc() in LESS CSS (Example) - Coderwall
Today I was banging my head that CSS3 calc() property was not working correctly in any browsers. Then I realized I am using...
Read more >A Complete Guide to calc() in CSS
CSS has a special calc() function for doing basic math. In this guide, let's cover just about everything there is to know about...
Read more >calc() - CSS: Cascading Style Sheets - MDN Web Docs
The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used with , , , , ,...
Read more >Using The CSS Function calc() Inside The LESS CSS ...
However, when I went to use it, I didn't get the expected value. calc() appears to conflict with a built-in function inside of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
they were probably closed as duplicates… though I can’t find one about calc… see #146 #122 and #915
workaround:
width: ~"calc(100% - @{id1width})";
- note curly brackets around variable.We are moving to a system where only things inside brackets will be evaluated to fix this problem.
height: ~“calc(100% - 50px)”; Worked for me.