[csswg-drafts] [css-values] Round to design grid module

Crissov has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Round to design grid module ==
Graphic designers often specify a rectangular grid using a fixed module, i.e. a relative or absolute length that other measures are an integer multiple or subdivision of. In stylesheets, often several length units are used for different purposes, e.g. font size in `pt`, line height in `em`, border width in `px`, margins in `mm`, widths in `%`, heights in `vh` and so on. To make them match up nicely and to assure the same results across different implementations, authors would need some method to influence or even control rounding behavior. Instead of classic `round(value, precision)`, `floor(value)` and `ceil(value)` functions found in many programming languages and spreadsheet applications, I believe CSS users would best be served by a _round to closest multiple_ function. For the reasons given in #905 I would call it `mod()`.

~~~~ css
mod(101px, 1pt) /* = 76pt ≈ 101.33px */
mod(100px, 1pt) /* = 75pt = 100px */
mod(99px, 1pt) /* = 74pt ≈ 98.67px */
mod(10px, 1pt) /* = 8pt ≈ 10.67px */
mod(1px, 1pt) /* = 1pt ≈ 1.33px */
~~~~

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2513 using your GitHub account

Received on Friday, 6 April 2018 13:21:08 UTC