Skip to content

Dividing Scalars in calc() #755

Closed
Closed
@nmn

Description

@nmn

Description

Calc currently doesn’t allow dividing one length by another.

Change this to allow dividing any pair of values than can be added and return a unit-less number. This number can then be used in various different scenarios.

A specification for this exists for many years. It’s possible to do this already using atan2() function with slightly buggy results in some browsers.

There are some very useful use cases where this would dramatically simplify layout code which would otherwise need a large number of container queries.

Specification

W3C: https://www.w3.org/TR/css-values-4/#calc-type-checking

Tests

css/css-values/getComputedStyle-calc-mixed-units-003.html
css/css-values/calc-in-media-queries-with-mixed-units.html

Browser bug reports

WebKit: https://bugs.webkit.org/show_bug.cgi?id=255280
Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1827404
Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1432187 and https://bugs.chromium.org/p/chromium/issues/detail?id=1213338

Additional Signals

This is a purely additive feature that should not cause any regressions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions