-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow removal of unit in calc() #10511
Comments
The spec does not mention when the restriction has been relaxed. I would like to know how long it has passed since the change. @cdoublev Do you know when the change in spec occurred? |
It seems like it was about 6 years ago: |
The spec explicitly lists this as a L4 addition. https://drafts.csswg.org/css-values-4/#additions-L3
|
Thanks to you both. I have added created new bug reports for Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1905736) as well as Chrome (https://issues.chromium.org/issues/350362795). Lets hope this feature will be available soon. |
There were actually already issues filed for this:
Sebastian |
Currently, it is not possible to remove unit from the result of
calc()
expression. In other words, we cannot convert fromlength
tonumber
.One use-case of removal of unit is when using
calc()
withzoom
property. For example, I want to usezoom
property in such a way that computed value ofzoom
is1
when viewport width is375px
, and it increases or decreases when width of viewport increases or decreases respectively.However, since there is no way to remove unit from the result of
calc()
, there is no way to make the above code work.The code below shows what I am trying to achieve. This makes use of
resize
event in JavaScript to update the value ofzoom
property. Once it is possible to remove unit fromcalc()
, there is no need of JavaScript to do so.The text was updated successfully, but these errors were encountered: