Skip to content

Commit d56b034

Browse files
committed
Added the 'fr' unit.
Changed the 'flex()' function to the new syntax discussed on the list.
1 parent 58ea996 commit d56b034

2 files changed

Lines changed: 203 additions & 81 deletions

File tree

css3-flexbox/Overview.html

Lines changed: 128 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
<h1 id=head-box-flexible>Flexible Box Layout Module</h1>
2323

24-
<h2 class="no-num no-toc" id=w3c-working>Editor's Draft, 8 April 2011</h2>
24+
<h2 class="no-num no-toc" id=w3c-working>Editor's Draft, 16 April 2011</h2>
2525

2626
<dl>
2727
<dt>This version:
2828

29-
<dd><!-- <a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20110408/">http://www.w3.org/TR/2011/WD-css3-flexbox-20110408/</a></dd> -->
29+
<dd><!-- <a href="http://www.w3.org/TR/2011/WD-css3-flexbox-20110416/">http://www.w3.org/TR/2011/WD-css3-flexbox-20110416/</a></dd> -->
3030
<a
3131
href="http://dev.w3.org/csswg/css3-flexbox/">http://dev.w3.org/csswg/css3-flexbox/</a>
3232

@@ -156,7 +156,10 @@ <h2 class="no-num no-toc" id=table>Table of contents</h2>
156156
<li><a href="#resolving-flexible-lengths"><span class=secno>5.1. </span>
157157
Resolving Flexible Lengths</a>
158158

159-
<li><a href="#flex-function"><span class=secno>5.2. </span> The
159+
<li><a href="#fraction-unit"><span class=secno>5.2. </span> The
160+
&lsquo;<code class=css>fr</code>&rsquo; unit</a>
161+
162+
<li><a href="#flex-function"><span class=secno>5.3. </span> The
160163
&lsquo;<code class=css>flex()</code>&rsquo; function</a>
161164
</ul>
162165

@@ -600,9 +603,9 @@ <h3 id=resolving-flexible-lengths><span class=secno>5.1. </span> Resolving
600603
flexbox, the lengths of the left and right margins, left and right
601604
borders, left and right paddings, and widths of all <a
602605
href="#flexbox-item"><i>flexbox item</i></a>s share the width of the
603-
flexbox itself. Conversely, each <i title="<i>flexbox item</i>s">flexbox
604-
item's</i> vertical margins, borders, padding, and height individually
605-
share the height of the flexbox.
606+
flexbox itself. Conversely, each <a href="#flexbox-item"><i>flexbox
607+
item</i></a>&lsquo;<code class=property>s</code>&rsquo; vertical margins,
608+
borders, padding, and height individually share the height of the flexbox.
606609

607610
<div class=figure>
608611
<p class="caption issue">TODO: Diagram showing the relevant lengths in
@@ -613,26 +616,17 @@ <h3 id=resolving-flexible-lengths><span class=secno>5.1. </span> Resolving
613616
in each set. The <a href="#preflex-size"><i>preflex size</i></a> of an
614617
inflexible length is just the length itself. The <a
615618
href="#preflex-size"><i>preflex size</i></a> of a flexible length is its
616-
<a href="#preferred-size"><i>preferred size</i></a>. The <dfn
617-
id=preferred-size>preferred size</dfn> defaults to &lsquo;<code
618-
class=css>0</code>&rsquo;, and can be set to a different value with the
619-
optional third argument to the &lsquo;<code class=css>flex()</code>&rsquo;
620-
function (defined below).
621-
622-
<p>If the sum of all the <a href="#preflex-size"><i title="preflex
623-
size">preflex sizes</i></a> is less than the available width/height of the
624-
flexbox, then the difference is split up among all the <a
625-
href="#flexible-length"><i title="flexible length">flexible
619+
<i>preferred size</i>. If the sum of all the <a href="#preflex-size"><i
620+
title="preflex size">preflex sizes</i></a> is less than the available
621+
width/height of the flexbox, then the difference is split up among all the
622+
<a href="#flexible-length"><i title="flexible length">flexible
626623
lengths</i></a> with <dfn id=positive-flexibility>positive
627-
flexibility</dfn> (a non-zero value for the first argument to the
628-
&lsquo;<code class=css>flex()</code>&rsquo; function), with the space
629-
divvied up proportionally to the flexibility of each length. If the sum is
630-
greater than the available width/height, then all the <a
631-
href="#flexible-length"><i title="flexible length">flexible
632-
lengths</i></a> with <dfn id=negative-flexibility>negative
633-
flexibility</dfn> (a non-zero value for the second argument to the
634-
&lsquo;<code class=css>flex()</code>&rsquo; function) shrink in proportion
635-
to their flexibility to try and make the sum equal the available
624+
flexibility</dfn>, with the space divvied up proportionally to the
625+
flexibility of each length. If the sum is greater than the available
626+
width/height, then all the <a href="#flexible-length"><i title="flexible
627+
length">flexible lengths</i></a> with <dfn
628+
id=negative-flexibility>negative flexibility</dfn> shrink in proportion to
629+
their flexibility to try and make the sum equal the available
636630
width/height.
637631

638632
<p>The &lsquo;<a href="#flex-pack0"><code
@@ -642,39 +636,113 @@ <h3 id=resolving-flexible-lengths><span class=secno>5.1. </span> Resolving
642636
precise details of how free space is determined and assigned to flexible
643637
lengths is detailed in a later chapter.
644638

645-
<h3 id=flex-function><span class=secno>5.2. </span> The &lsquo;<code
639+
<h3 id=fraction-unit><span class=secno>5.2. </span> The &lsquo;<code
640+
class=css>fr</code>&rsquo; unit</h3>
641+
642+
<p>The &lsquo;<code class=css>fr</code>&rsquo; unit, defined in the Values
643+
and Units spec <a href="#CSS3VAL"
644+
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a>, can be used to specify a
645+
flexible length. When the &lsquo;<code class=css>fr</code>&rsquo; unit is
646+
used, the <i>preferred size</i> of the length is &lsquo;<code
647+
class=css>0</code>&rsquo;, the <a href="#positive-flexibility"><i>positive
648+
flexibility</i></a> is equal to the numeric part of the value, and the <a
649+
href="#negative-flexibility"><i>negative flexibility</i></a> is
650+
&lsquo;<code class=css>0</code>&rsquo;.
651+
652+
<h3 id=flex-function><span class=secno>5.3. </span> The &lsquo;<code
646653
class=css>flex()</code>&rsquo; function</h3>
647654

648655
<p>The &lsquo;<code class=css>flex()</code>&rsquo; function is used to
649656
specify the parameters of a <a href="#flexible-length"><i>flexible
650657
length</i></a>: the <a href="#positive-flexibility"><i title="positive
651658
flexibility">positive</i></a> and <a
652-
href="#negative-flexibility"><i>negative flexibility</i></a>, and the <a
653-
href="#preferred-size"><i>preferred size</i></a>. The syntax of the
654-
&lsquo;<code class=css>flex()</code>&rsquo; function is:
659+
href="#negative-flexibility"><i>negative flexibility</i></a>, and the
660+
<i>preferred size</i>. The syntax of the &lsquo;<code
661+
class=css>flex()</code>&rsquo; function is roughly (see following prose
662+
for a precise description):
655663

656664
<pre
657-
class=prod>flex( <a href="#positive-flexibility"><i title="positive flexibility">&lt;pos-flex></i></a> [, <a href="#negative-flexibility"><i title="negative flexibility">&lt;neg-flex></i></a> [, <a href="#preferred-size"><i title="preferred size">&lt;preferred-size></i></a> ]? ]? )</pre>
658-
659-
<p>The first argument sets the <a href="#positive-flexibility"><i>positive
660-
flexibility</i></a> of the length. It must be a non-negative &lt;number> -
661-
anything else is a syntax error.
662-
663-
<p>The second argument sets the <a href="#negative-flexibility"><i>negative
664-
flexibility</i></a> of the length. It must also be a non-negative
665-
&lt;number>, with anything else being a syntax error. This argument is
666-
optional; if omitted, it defaults to &lsquo;<code
667-
class=css>0</code>&rsquo;.
668-
669-
<p>The third and final argument sets the <a
670-
href="#preferred-size"><i>preferred size</i></a> of the length. It must be
671-
a &lt;length> or a &lt;percentage>, or the keyword &lsquo;<code
672-
class=css>auto</code>&rsquo; - anything else is a syntax error. This
673-
argument is also optional; if omitted, it defaults to &lsquo;<code
674-
class=css>0</code>&rsquo;.
675-
676-
<p class=issue>The precise syntax of the flex() function is still under
677-
discussion.</p>
665+
class=prod>flex( [ <a href="#positive-flexibility"><i title="positive flexibility">&lt;pos-flex></i></a> || <!--
666+
--><a href="#negative-flexibility"><i title="negative flexibility">&lt;neg-flex></i></a> || <!--
667+
--><i title="preferred size">&lt;preferred-size></i> ] )</pre>
668+
669+
<dl>
670+
<dt>If the &lsquo;<code class=css>flex()</code>&rsquo; function contains a
671+
single value:
672+
673+
<dd>
674+
<ul>
675+
<li>If the value is a non-negative number, the <a
676+
href="#positive-flexibility"><i>positive flexibility</i></a> is set to
677+
that value, the <a href="#negative-flexibility"><i>negative
678+
flexibility</i></a> is set to &lsquo;<code class=css>0</code>&rsquo;,
679+
and the <i>preferred size</i> is set to &lsquo;<code
680+
class=css>auto</code>&rsquo;.
681+
682+
<li>Otherwise, if the value is a &lt;length>, a &lt;percentage>, or a
683+
valid keyword for &lsquo;<code class=property>width</code>&rsquo; or
684+
&lsquo;<code class=property>height</code>&rsquo;, the <i>preferred
685+
size</i> is set to that value, the <a
686+
href="#positive-flexibility"><i>positive flexibility</i></a> is set to
687+
1, and the <a href="#negative-flexibility"><i>negative
688+
flexibility</i></a> is set to &lsquo;<code class=css>0</code>&rsquo;.
689+
690+
<li>Otherwise, the &lsquo;<code class=css>flex()</code>&rsquo; function
691+
is invalid.
692+
</ul>
693+
694+
<dt>If the &lsquo;<code class=css>flex()</code>&rsquo; function contains
695+
two values:
696+
697+
<dd>
698+
<ul>
699+
<li>If both values are non-negative numbers, the <a
700+
href="#positive-flexibility"><i>positive flexibility</i></a> is set to
701+
the first value, the <a href="#negative-flexibility"><i>negative
702+
flexibility</i></a> is set to the second value, and the <i>preferred
703+
size</i> is set to &lsquo;<code class=css>auto</code>&rsquo;.
704+
705+
<li>Otherwise, if one value is a non-negative integer and the other is a
706+
&lt;length>, a &lt;percentage>, or a valid keyword for &lsquo;<code
707+
class=property>width</code>&rsquo; or &lsquo;<code
708+
class=property>height</code>&rsquo;, the <a
709+
href="#positive-flexibility"><i>positive flexibility</i></a> is set to
710+
the number, the <a href="#negative-flexibility"><i>negative
711+
flexibility</i></a> is set to &lsquo;<code class=css>0</code>&rsquo;,
712+
and the <i>preferred size</i> is set to &lsquo;<code
713+
class=css>auto</code>&rsquo;.
714+
715+
<li>Otherwise, the &lsquo;<code class=css>flex()</code>&rsquo; function
716+
is invalid.
717+
</ul>
718+
719+
<dt>If the &lsquo;<code class=css>flex()</code>&rsquo; function contains
720+
three values:
721+
722+
<dd>
723+
<ul>
724+
<li>If two of the values are non-negative numbers, and the other is a
725+
&lt;length> (with a unit suffix), a &lt;percentage>, or a valid keyword
726+
for &lsquo;<code class=property>width</code>&rsquo; or &lsquo;<code
727+
class=property>height</code>&rsquo;, the <a
728+
href="#positive-flexibility"><i>positive flexibility</i></a> is set to
729+
the first number, the <a href="#negative-flexibility"><i>negative
730+
flexibility</i></a> is set to the second number, and the <i>preferred
731+
size</i> is set to the other value.
732+
733+
<li>Otherwise, the &lsquo;<code class=css>flex()</code>&rsquo; function
734+
is invalid.
735+
</ul>
736+
</dl>
737+
738+
<p class=note>Note that, while &lsquo;<code class=css>0</code>&rsquo;
739+
&lt;length>s are normally allowed to be specified without a unit suffix,
740+
the definition of the &lsquo;<code class=css>flex()</code>&rsquo; function
741+
implicitly disallows this. Allowing a unitless &lsquo;<code
742+
class=css>0</code>&rsquo; length would cause ambiguity in some cases; even
743+
in the unambiguous cases, the flexible length could instead be written
744+
using the &lsquo;<code class=css>fr</code>&rsquo; unit, which is shorter
745+
and simpler.</p>
678746
<!-- ====================================================================== -->
679747

680748
<h2 id=flex-pack><span class=secno>6. </span> The &lsquo;<a
@@ -1352,6 +1420,16 @@ <h3 class=no-num id=normative>Normative references</h3>
13521420
href="http://www.w3.org/TR/2010/WD-CSS2-20101207">http://www.w3.org/TR/2010/WD-CSS2-20101207</a>
13531421
</dd>
13541422
<!---->
1423+
1424+
<dt id=CSS3VAL>[CSS3VAL]
1425+
1426+
<dd>Chris Lilley; H&#229;kon Wium Lie. <a
1427+
href="http://www.w3.org/TR/2006/WD-css3-values-20060919"><cite>CSS3
1428+
Values and Units.</cite></a> 19 September 2006. W3C Working Draft. (Work
1429+
in progress.) URL: <a
1430+
href="http://www.w3.org/TR/2006/WD-css3-values-20060919">http://www.w3.org/TR/2006/WD-css3-values-20060919</a>
1431+
</dd>
1432+
<!---->
13551433
</dl>
13561434
<!--end-normative-->
13571435

@@ -1424,9 +1502,6 @@ <h2 class=no-num id=index>Index</h2>
14241502
<li>positive flexibility, <a href="#positive-flexibility" title="positive
14251503
flexibility"><strong>5.1.</strong></a>
14261504

1427-
<li>preferred size, <a href="#preferred-size" title="preferred
1428-
size"><strong>5.1.</strong></a>
1429-
14301505
<li>preflex size, <a href="#preflex-size" title="preflex
14311506
size"><strong>5.1.</strong></a>
14321507

css3-flexbox/Overview.src.html

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ <h2 id=flex-direction>
285285

286286
<!-- ====================================================================== -->
287287

288-
<h2 id=flex-order>
288+
<h2 id='flex-order'>
289289
Display Order: the 'flex-order' property</h2>
290290

291291
<p><i>flexbox item</i>s are, by default, displayed and laid out in the same order
@@ -373,7 +373,7 @@ <h3 id='resolving-flexible-lengths'>
373373
all the lengths, flexible or inflexible, that will share some space. For example,
374374
for a horizontal flexbox, the lengths of the left and right margins, left and right
375375
borders, left and right paddings, and widths of all <i>flexbox item</i>s share
376-
the width of the flexbox itself. Conversely, each <i title="<i>flexbox item</i>s">flexbox item's</i>
376+
the width of the flexbox itself. Conversely, each <i>flexbox item</i>'s'
377377
vertical margins, borders, padding, and height individually share the height
378378
of the flexbox.</p>
379379

@@ -384,48 +384,95 @@ <h3 id='resolving-flexible-lengths'>
384384

385385
<p>CSS then sums the <dfn>preflex size</dfn> of the lengths in each set. The
386386
<i>preflex size</i> of an inflexible length is just the length itself. The
387-
<i>preflex size</i> of a flexible length is its <i>preferred size</i>. The
388-
<dfn>preferred size</dfn> defaults to ''0'', and can be set to a different value
389-
with the optional third argument to the ''flex()'' function (defined below).</p>
390-
391-
<p>If the sum of all the <i title="preflex size">preflex sizes</i> is less than
392-
the available width/height of the flexbox, then the difference is split up among all the
393-
<i title="flexible length">flexible lengths</i> with <dfn>positive flexibility</dfn>
394-
(a non-zero value for the first argument to the ''flex()'' function), with the
395-
space divvied up proportionally to the flexibility of each length. If the sum
396-
is greater than the available width/height, then all the
387+
<i>preflex size</i> of a flexible length is its <i>preferred size</i>. If the
388+
sum of all the <i title="preflex size">preflex sizes</i> is less than the
389+
available width/height of the flexbox, then the difference is split up among all the
390+
<i title="flexible length">flexible lengths</i> with <dfn>positive flexibility</dfn>,
391+
with the space divvied up proportionally to the flexibility of each length. If
392+
the sum is greater than the available width/height, then all the
397393
<i title="flexible length">flexible lengths</i> with <dfn>negative flexibility</dfn>
398-
(a non-zero value for the second argument to the ''flex()'' function) shrink
399-
in proportion to their flexibility to try and make the sum equal the available
400-
width/height.</p>
394+
shrink in proportion to their flexibility to try and make the sum equal the
395+
available width/height.</p>
401396

402397
<p>The 'flex-pack' and 'flex-align' properties offer more complex control over
403398
free-space distribution. The precise details of how free space is determined
404399
and assigned to flexible lengths is detailed in a later chapter.</p>
400+
401+
<h3 id='fraction-unit'>
402+
The ''fr'' unit</h3>
403+
404+
<p>The ''fr'' unit, defined in the Values and Units spec [[!CSS3VAL]], can be
405+
used to specify a flexible length. When the ''fr'' unit is used, the <i>preferred size</i>
406+
of the length is ''0'', the <i>positive flexibility</i> is equal to the numeric
407+
part of the value, and the <i>negative flexibility</i> is ''0''.</p>
405408

406-
<h3 id=flex-function>
409+
<h3 id='flex-function'>
407410
The ''flex()'' function</h3>
408411

409412
<p>The ''flex()'' function is used to specify the parameters of a
410413
<i>flexible length</i>: the <i title="positive flexibility">positive</i>
411414
and <i>negative flexibility</i>, and the <i>preferred size</i>. The syntax
412-
of the ''flex()'' function is:</p>
415+
of the ''flex()'' function is roughly (see following prose for a precise
416+
description):</p>
413417

414-
<pre class=prod>flex( <i title="positive flexibility">&lt;pos-flex></i> [, <i title="negative flexibility">&lt;neg-flex></i> [, <i title="preferred size">&lt;preferred-size></i> ]? ]? )</pre>
418+
<pre class=prod>flex( [ <i title="positive flexibility">&lt;pos-flex></i> || <!--
419+
--><i title="negative flexibility">&lt;neg-flex></i> || <!--
420+
--><i title="preferred size">&lt;preferred-size></i> ] )</pre>
415421

416-
<p>The first argument sets the <i>positive flexibility</i> of the length.
417-
It must be a non-negative &lt;number> - anything else is a syntax error.</p>
422+
<dl>
423+
<dt>If the ''flex()'' function contains a single value:</dt>
424+
<dd>
425+
<ul>
426+
<li>If the value is a non-negative number, the <i>positive flexibility</i>
427+
is set to that value, the <i>negative flexibility</i> is set to
428+
''0'', and the <i>preferred size</i> is set to ''auto''.</li>
429+
430+
<li>Otherwise, if the value is a &lt;length>, a &lt;percentage>,
431+
or a valid keyword for 'width' or 'height', the <i>preferred size</i>
432+
is set to that value, the <i>positive flexibility</i> is set to
433+
1, and the <i>negative flexibility</i> is set to ''0''.</li>
434+
435+
<li>Otherwise, the ''flex()'' function is invalid.</li>
436+
</ul>
437+
</dd>
418438

419-
<p>The second argument sets the <i>negative flexibility</i> of the length.
420-
It must also be a non-negative &lt;number>, with anything else being a syntax
421-
error. This argument is optional; if omitted, it defaults to ''0''.</p>
439+
<dt>If the ''flex()'' function contains two values:</dt>
440+
<dd>
441+
<ul>
442+
<li>If both values are non-negative numbers, the <i>positive flexibility</i>
443+
is set to the first value, the <i>negative flexibility</i> is set
444+
to the second value, and the <i>preferred size</i> is set to ''auto''.</li>
445+
446+
<li>Otherwise, if one value is a non-negative integer and the other
447+
is a &lt;length>, a &lt;percentage>, or a valid keyword for 'width'
448+
or 'height', the <i>positive flexibility</i> is set to the number, the
449+
<i>negative flexibility</i> is set to ''0'', and the <i>preferred size</i>
450+
is set to ''auto''.</li>
451+
452+
<li>Otherwise, the ''flex()'' function is invalid.</li>
453+
</ul>
454+
</dd>
422455

423-
<p>The third and final argument sets the <i>preferred size</i> of the length.
424-
It must be a &lt;length> or a &lt;percentage>, or the keyword ''auto'' -
425-
anything else is a syntax error. This argument is also optional; if omitted,
426-
it defaults to ''0''.</p>
456+
<dt>If the ''flex()'' function contains three values:</dt>
457+
<dd>
458+
<ul>
459+
<li>If two of the values are non-negative numbers, and the other
460+
is a &lt;length> (with a unit suffix), a &lt;percentage>, or a
461+
valid keyword for 'width' or 'height', the <i>positive flexibility</i>
462+
is set to the first number, the <i>negative flexibility</i> is set
463+
to the second number, and the <i>preferred size</i> is set to the
464+
other value.</li>
465+
466+
<li>Otherwise, the ''flex()'' function is invalid.</li>
467+
</ul>
468+
</dd>
469+
</dt>
427470

428-
<p class=issue>The precise syntax of the flex() function is still under discussion.</p>
471+
<p class='note'>Note that, while ''0'' &lt;length>s are normally allowed to
472+
be specified without a unit suffix, the definition of the ''flex()'' function
473+
implicitly disallows this. Allowing a unitless ''0'' length would cause
474+
ambiguity in some cases; even in the unambiguous cases, the flexible length
475+
could instead be written using the ''fr'' unit, which is shorter and simpler.</p>
429476

430477

431478
<!-- ====================================================================== -->

0 commit comments

Comments
 (0)