Re: [csswg-drafts] [css-values] Re-adding min() and max()?

The proposed syntax is that <code>min()</code> and <code>max()</code> 
are functions.  <code>min()</code> results in the smallest of its (1 
or more) arguments, and <code>max()</code> results in the largest of 
its arguments.

One of the issues with adding a minimum and a maximum constraint to a 
value (as in 
https://github.com/w3c/csswg-drafts/issues/544#issuecomment-272489981)
 is that there are two options to how to process them, which produce 
different results when the minimum is greater than the maximum.  CSS 
generally treats the minimum as winning, so that the standard CSS way 
to enforce a minimum and maximum constraint on a value is 
<code>max(minimum, min(maximum, starting value))</code>.  However, if 
you want, you can also write <code>min(maximum, max(minimum, starting 
value))</code> which would do the opposite when <code>minimum > 
maximum</code>.

But, in general, the functions allow you to combine values in other 
ways.  For example, you can write things like <code>max(500px, 20em, 
30vw)</code> which would result in the largest of the three arguments.

The further syntax proposal for allowing these to appear at top level 
is that, while these are functions that conceptually live inside of 
<code>calc()</code>, you're allowed to abbreviate 
<code>calc(min(500px, 30vw))</code> by dropping the 
<code>calc()</code> on the outside and just writing <code>min(500px, 
30vw)</code>.  <code>min()</code> and <code>max()</code> become 
toplevel functions that are allowed anywhere <code>calc()</code> is 
allowed, and just mean <code>calc(min())</code>, etc.  This was the 
way I structured the original <code>min()</code> and 
<code>max()</code> proposal when I initially proposed 
<code>calc()</code>.

-- 
GitHub Notification of comment by dbaron
Please view or discuss this issue at 
https://github.com/w3c/csswg-drafts/issues/544#issuecomment-272501187 
using your GitHub account

Received on Friday, 13 January 2017 17:48:13 UTC