W3C home > Mailing lists > Public > www-style@w3.org > May 2013

[css3-values] calc() division with units

From: John Mellor <johnme@chromium.org>
Date: Wed, 29 May 2013 14:51:22 +0100
Message-ID: <CAG_kaUaJV6GWG_LuBTL25yOoy3KzGyCR1+Lsb_2ozLXNjtbNVQ@mail.gmail.com>
To: www-style list <www-style@w3.org>
Some interesting use cases for calc() currently seem impossible due to the
way units work when dividing values.

For example to (roughly) estimate the height of a long line of text which
has wrapped on a narrow screen, you need to divide the total width of the
line of text by the viewport width. Supposing you know the text contains
237 characters:

number of lines ~= 237ex / 100vw

So if your line-height is 1.2em, you might try to estimate the wrapped
height using:

height: calc(237ex / 100vw * 1.2em)

Mathematically, this is fine, as <length>/<length>*<length> == <length>.

But 8.1.2. Type
Checking<http://dev.w3.org/csswg/css-values/#calc-type-checking> for
'/' requires "check that the right side is <number>", and so this
expression is (unnecessarily) deemed invalid.

Can we relax this requirement, and just require the final computed value to
be of an appropriate type?

Received on Wednesday, 29 May 2013 13:52:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:30 UTC