Comments (10)
What is the point of this? Browser that will understand vw probably understand calc().
And not even sure this is correct. vw is a dynamic unit, I don't know how you end up with this weird result.
Could you add some details?
from postcss-calc.
Point is minimization. Maybe it's better to move this ticket to cssnano. But then I thought which project suits better I choose this one, cause it does almost same thing.
from postcss-calc.
Can you provide detail about the algorithm here? Or just how you end up with this result. I am not following the result your mentioned.
from postcss-calc.
That's quite easy, just distributive property applied.
14px + 6 * ((100vw - 320px) / 448) =
= 14px + 6 * ((100/448)vw - (320/448)px) =
= 14px + (6*100/448)vw - (6*320/448)px =
= (6*100/448)vw + (14 - 6*320/448)px ≈ 1.3392857143vw + 9.7142857143px
from postcss-calc.
Not sure that ((100vw - 320px) / 448)
can be converted to ((100/448)vw - (320/448)px)
. That's seems too easy. Did you try the result in a browser just to see?
from postcss-calc.
Of course, steps in the middle are not working. I've provided them just to show idea of transformation. You have to calculate (0.2232142857vw - 0.7142857143px
) to make it working.
from postcss-calc.
But when it's calculated they provide same result, i've checked.
from postcss-calc.
Feel free to make a PR to https://github.com/MoOx/reduce-css-calc if you have something solid (a jsfiddle with detailed step would be appreciated as well as test).
from postcss-calc.
Resolved in https://github.com/postcss/postcss-calc/releases/tag/v6.0.0.
from postcss-calc.
Will be resolved for version 4, see https://github.com/postcss/postcss-calc/releases/tag/v6.0.0.
from postcss-calc.
Related Issues (20)
- Direct CSS input HOT 2
- 3-level deep var()s inside a calc() throw an error HOT 3
- Compile wrong with CSS custom properties
- wrong/insufficient reduction HOT 2
- Support min, max, clamp HOT 2
- Simple var multiplication breaks HOT 5
- Space between multiplication and division operators is clamped with custom properties HOT 3
- Move postcss to peerDependencies HOT 2
- error compiling valid calc expression
- FATAL Nuxt build error HOT 1
- Floating number with unknown unit can't be parsed HOT 3
- Fails with SCSS variables HOT 2
- "ParserError: Syntax Error" with negative multiplication and vars HOT 4
- Please do not calculate the percentage in calc()
- ChainAlert: npm version 8.1.0 has new or changed maintainer HOT 2
- [Bug]: repository not shown on npmjs.com
- [Bug]: `calc` disappears if extra pair of parentheses around the argument
- [Bug]: Remove duplicate repository field in package.json
- [Feature Request]: Support for `min()` and `max()` HOT 1
- [Bug]: Lexical error on line ... : Unrecognized text.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postcss-calc.