Home > Web Front-end > CSS Tutorial > How Can I Prevent Less Compilers from Incorrectly Translating CSS `calc()` Properties?

How Can I Prevent Less Compilers from Incorrectly Translating CSS `calc()` Properties?

DDD
Release: 2024-12-20 12:40:18
Original
866 people have browsed it

How Can I Prevent Less Compilers from Incorrectly Translating CSS `calc()` Properties?

Less Compilation Issues with CSS calc() Properties: Prevention Methods

Less compilers, such as OrangeBits and dotless, have been known to incorrectly translate CSS calc() properties. This can lead to undesired results, such as converting "calc(100% - 250px - 1.5em)" to "calc(-151.5%)".

To prevent this, Less version 3.00 onwards no longer evaluates expressions within calc() by default. This change ensures that calc() values are preserved during compilation.

For Less versions prior to 3.00:

To prevent less from translating calc equations you can use tilde notation like so:

body { width: calc(~"100% - 250px - 1.5em"); }
Copy after login

The above is the detailed content of How Can I Prevent Less Compilers from Incorrectly Translating CSS `calc()` Properties?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template