- From: L. David Baron <dbaron@dbaron.org>
- Date: Wed, 16 Dec 2009 19:17:40 -0500
- To: www-style@w3.org
For a number of CSS properties, negative values are parse errors. Some of these, such as 'width', are very important use cases for 'calc()' ( http://dev.w3.org/csswg/css3-values/#the-calc-function ). (There are also a few properties that disallow negative and zero values: 'column-count', 'widows', and 'orphans', but they're not as relevant here since they're all integer-valued properties, to which calc() doesn't currently apply.) It's not entirely clear to me how we should deal with negative values interacting with calc() in such cases. However, I'd like to make the following strawman proposal so that we at least have *some* proposal for handling this: 1. While parsing the contents of the calc(), values are accepted even if, were they the lone value of the property, they would be rejected due to their sign (or any other range restriction on the value of the property). For example: width: calc(50% + -2px); is a valid declaration even though -2px is not a valid value for the 'width' property. 2. For properties whose values have restricted ranges, the computed value of the calc() expression is clamped to the allowed range. For example: width: calc(50% - 200px); computes to zero when the containing block's width is less than or equal to 400px (whereas without the clamping it would become negative when the containing block's width is less than 400px). Note that this proposal applies equally to min() and max(), although for min() and max() at toplevel (i.e., not inside calc()), there are other reasonable solutions possible (although they complicate implementation). -David -- L. David Baron http://dbaron.org/ Mozilla Corporation http://www.mozilla.com/
Received on Thursday, 17 December 2009 01:39:22 UTC