Skip to content

Commit 1c60cb4

Browse files
committed
changed flex() function to 'flex' property
a few small editorial changes
1 parent f1014a8 commit 1c60cb4

2 files changed

Lines changed: 278 additions & 93 deletions

File tree

css3-flexbox/Overview.html

Lines changed: 177 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ <h2 class="no-num no-toc" id=table>Table of contents</h2>
214214
</ul>
215215

216216
<li><a href="#flexibility"><span class=secno>4. </span> Flexibility: the
217-
&lsquo;<code class=css>flex()</code>&rsquo; notation</a>
217+
&lsquo;<code class=property>flex</code>&rsquo; property</a>
218218

219219
<li><a href="#alignment"><span class=secno>5. </span> Alignment</a>
220220
<ul class=toc>
@@ -341,10 +341,7 @@ <h2 id=intro><span class=secno>1. </span> Introduction</h2>
341341
<h3 id=placement><span class=secno>1.1. </span> Module interactions</h3>
342342

343343
<p>This module extends the definition of the &lsquo;<code
344-
class=property>display</code>&rsquo; property. It also defines a new type
345-
of primitive value, the <a href="#flex-function">flex() notation</a>,
346-
which is accepted by the &lsquo;<code class=property>width</code>&rsquo;
347-
and &lsquo;<code class=property>height</code>&rsquo; properties.
344+
class=property>display</code>&rsquo; property.
348345

349346
<h3 id=values><span class=secno>1.2. </span> Values</h3>
350347

@@ -418,19 +415,17 @@ <h2 id=box-model><span class=secno>2. </span> The Flexbox Box Model</h2>
418415
<p>The contents of a flexbox can be easily and powerfully manipulated with
419416
a handful of properties. Most significantly, <a
420417
href="#flexbox-item"><i>flexbox items</i></a> can "flex" their <a
421-
href="#main-size"><i>main size</i></a> by using the &lsquo;<code
422-
class=css>flex()</code>&rsquo; function in the &lsquo;<code
423-
class=property>width</code>&rsquo; or &lsquo;<code
424-
class=property>height</code>&rsquo; property. This "flexing" allows the
425-
items to get bigger or smaller based on the available space in the page.
426-
If there is leftover space in the flexbox after all of the <a
427-
href="#flexbox-item"><i>flexbox items</i></a> have finished flexing, the
428-
items can be aligned, centered, or distributed with the &lsquo;<a
429-
href="#flex-pack0"><code class=property>flex-pack</code></a>&rsquo;
430-
property. <a href="#flexbox-item"><i>Flexbox items</i></a> can also be
431-
completely rearranged within the flexbox with the &lsquo;<a
432-
href="#flex-order0"><code class=property>flex-order</code></a>&rsquo;
433-
property.
418+
href="#main-size"><i>main size</i></a> by using the &lsquo;<a
419+
href="#flex"><code class=property>flex</code></a>&rsquo; property. This
420+
"flexing" allows the items to get bigger or smaller based on the available
421+
space in the page. If there is leftover space in the flexbox after all of
422+
the <a href="#flexbox-item"><i>flexbox items</i></a> have finished
423+
flexing, the items can be aligned, centered, or distributed with the
424+
&lsquo;<a href="#flex-pack0"><code
425+
class=property>flex-pack</code></a>&rsquo; property. <a
426+
href="#flexbox-item"><i>Flexbox items</i></a> can also be completely
427+
rearranged within the flexbox with the &lsquo;<a href="#flex-order0"><code
428+
class=property>flex-order</code></a>&rsquo; property.
434429

435430
<p>In the <a href="#cross-axis"><i>cross axis</i></a>, <a
436431
href="#flexbox-item"><i>flexbox items</i></a> can either "flex" to fill
@@ -509,6 +504,13 @@ <h3 id=display-flexbox><span class=secno>2.1. </span> New values for
509504
Additionally, each of the <a href="#flexbox-item"><i>flexbox items</i></a>
510505
establish a new formatting context for its contents.
511506

507+
<p class=issue>Although the term "flexbox formatting context" is defined
508+
here, it is not used anywhere else. BFC is the commonly used term for what
509+
it means here. Perhaps this could say that flexbox formatting context *is*
510+
a block formatting context, with different rules for how blocks are
511+
formatted but same protection from external floats etc. Then the terms can
512+
be used interchangeably, as they will be anyway...
513+
512514
<h3 id=flex-items><span class=secno>2.2. </span> Flexbox Items</h3>
513515

514516
<p class=issue>Add a &lsquo;<code
@@ -1001,10 +1003,6 @@ <h3 id=flex-order><span class=secno>3.4. </span> Display Order: the
10011003
.tabs > .current {
10021004
flex-order: -1; /* Lower than the default of 0 */
10031005
}</pre>
1004-
1005-
<p>You can also see a <a href=flex-order-example.html>working example</a>
1006-
in some modern browsers (modern WebKit, Firefox, or any browser that
1007-
supports the Flexbox spec).</p>
10081006
</div>
10091007

10101008
<div class=example>
@@ -1040,7 +1038,7 @@ <h3 id=flex-order><span class=secno>3.4. </span> Display Order: the
10401038

10411039
<pre>
10421040
#main { display: flexbox; }
1043-
#main > article { width: flex(1); flex-order: 2; }
1041+
#main > article { flex:1; flex-order: 2; }
10441042
#main > nav { width: 200px; flex-order: 1; }
10451043
#main > aside { width: 200px; flex-order: 3; }</pre>
10461044

@@ -1063,73 +1061,128 @@ <h3 id=flex-order><span class=secno>3.4. </span> Display Order: the
10631061
intelligent wrapping left as an exercise for the reader.)</small></p>
10641062
</div>
10651063

1066-
<h2 id=flexibility><span class=secno>4. </span> Flexibility: the
1067-
&lsquo;<code class=css>flex()</code>&rsquo; notation</h2>
1064+
<h2 id=flexibility><span class=secno>4. </span> Flexibility: the &lsquo;<a
1065+
href="#flex"><code class=property>flex</code></a>&rsquo; property</h2>
10681066

10691067
<p>The defining aspect of flexbox layout is the ability to make the <a
10701068
href="#flexbox-item"><i>flexbox items</i></a> "flex", altering their width
10711069
or height to fill the available space. This is done by using a &lsquo;<a
1072-
href="#ltflex"><code class=css>&lt;flex></code></a>&rsquo; value in the
1073-
element's &lsquo;<code class=property>width</code>&rsquo; or &lsquo;<code
1074-
class=property>height</code>&rsquo; property. A flexbox distributes free
1075-
space to its items proportional to their positive flexibility, or shrinks
1076-
them to prevent overflow proportional to their negative flexibility.
1077-
1078-
<p>The &lsquo;<code class=css>flex()</code>&rsquo; notation is used to
1079-
specify the parameters of a <dfn id=flexible-length
1070+
href="#flex"><code class=property>flex</code></a>&rsquo; property. A
1071+
flexbox distributes free space to its items proportional to their positive
1072+
flexibility, or shrinks them to prevent overflow proportional to their
1073+
negative flexibility.
1074+
1075+
<table class=propdef>
1076+
<tbody>
1077+
<tr>
1078+
<th>Name:
1079+
1080+
<td><dfn id=flex>flex</dfn>
1081+
1082+
<tr>
1083+
<th><a href="http://dev.w3.org/csswg/css-module/#values">Value</a>:
1084+
1085+
<td>[[ &lt;pos-flex> &lt;neg-flex>? ]? &amp;&amp;
1086+
[&lt;preferred-size>]?] | none
1087+
1088+
<tr>
1089+
<th>Initial:
1090+
1091+
<td>none
1092+
1093+
<tr>
1094+
<th>Applies to:
1095+
1096+
<td>flexbox items
1097+
1098+
<tr>
1099+
<th>Inherited:
1100+
1101+
<td>no
1102+
1103+
<tr>
1104+
<th>Computed Value:
1105+
1106+
<td>specified value
1107+
1108+
<tr>
1109+
<th>Media:
1110+
1111+
<td>visual
1112+
1113+
<tr>
1114+
<th>Animatable:
1115+
1116+
<td>yes
1117+
</table>
1118+
1119+
<p class=note><b>Editorial note:</b> in a property, default preferred size
1120+
of zero is problematic. If flex property is not specified, &lsquo;<code
1121+
class=property>width</code>&rsquo; or &lsquo;<code
1122+
class=property>height</code>&rsquo; must be used, which corresponds to
1123+
preferred size of &lsquo;<code class=property>auto</code>&rsquo;. But if
1124+
flex is specified, we want default preferred size of 0px. The new keyword
1125+
&lsquo;<a href="#flex-flow-none"><code
1126+
class=property>none</code></a>&rsquo; is the way around it.
1127+
1128+
<p>The &lsquo;<a href="#flex"><code class=property>flex</code></a>&rsquo;
1129+
property specifiex the parameters of a <dfn id=flexible-length
10801130
title="flexible length|flexible lengths|flexible length's">flexible
10811131
length</dfn>: the <dfn id=positive-flexibility
10821132
title="positive flexibility">positive</dfn> and <dfn
10831133
id=negative-flexibility>negative flexibility</dfn>, and the <dfn
1084-
id=preferred-size>preferred size</dfn>. The syntax of the &lsquo;<code
1085-
class=css>flex()</code>&rsquo; notation is:
1086-
1087-
<pre class=prod><dfn
1088-
id=ltflex>&lt;flex></dfn> = flex( [ &lt;pos-flex> &lt;neg-flex>? ]? &amp;&amp; &lt;preferred-size>? )</pre>
1134+
id=preferred-size>preferred size</dfn>.
10891135

10901136
<p><code>&lt;pos-flex></code> and <code>&lt;neg-flex></code> are
10911137
non-negative <code>&lt;numbers>s</code>, while
1092-
<code>&lt;preferred-size></code> is any value (other than another
1093-
&lsquo;<a href="#ltflex"><code class=css>&lt;flex></code></a>&rsquo;) that
1094-
would be valid in the &lsquo;<code class=property>width</code>&rsquo; or
1095-
&lsquo;<code class=property>height</code>&rsquo; property in which the
1096-
notation is used. If the <code>&lt;preferred-size></code> is &lsquo;<code
1138+
<code>&lt;preferred-size></code> is any value that would be valid in the
1139+
&lsquo;<code class=property>width</code>&rsquo; or &lsquo;<code
1140+
class=property>height</code>&rsquo; property. If the
1141+
<code>&lt;preferred-size></code> is &lsquo;<code
10971142
class=css>0</code>&rsquo;, it <strong>must</strong> be specified with a
10981143
unit (like &lsquo;<code class=css>0px</code>&rsquo;) to avoid ambiguity;
10991144
unitless zero will either be interpreted as as one of the flexibilities,
11001145
or is a syntax error.
11011146

1102-
<p>The <code>&lt;pos-flex></code> component sets the length's <a
1147+
<p>The <code>&lt;pos-flex></code> component sets the <a
11031148
href="#positive-flexibility"><i>positive flexibility</i></a>; if omitted,
11041149
the <a href="#positive-flexibility"><i>positive flexibility</i></a>
11051150
defaults to &lsquo;<code class=css>1</code>&rsquo;. The
1106-
<code>&lt;neg-flex></code> component sets the length's <a
1151+
<code>&lt;neg-flex></code> component sets the <a
11071152
href="#negative-flexibility"><i>negative flexibility</i></a>; if omitted,
1108-
it defaults to &lsquo;<code class=css>0</code>&rsquo;. The
1109-
<code>&lt;preferred-size></code> component sets the length's <a
1153+
it defaults to &lsquo;<code class=css>0</code>&rsquo;.
1154+
1155+
<p>The <code>&lt;preferred-size></code> component sets the <a
11101156
href="#preferred-size"><i>preferred size</i></a>; if omitted, it defaults
1111-
to &lsquo;<code class=css>0px</code>&rsquo;.
1112-
1113-
<p>If the &lsquo;<code class=css>flex()</code>&rsquo; notation is specified
1114-
on an element that is not a <a href="#flexbox-item"><i>flexbox
1115-
item</i></a>, it computes to the <a href="#preferred-size"><i>preferred
1116-
size</i></a>. If the &lsquo;<code class=css>flex()</code>&rsquo; notation
1117-
is used on a <a href="#flexbox-item"><i>flexbox item's</i></a> <a
1118-
href="#cross-size-property"><i>cross size property</i></a>, it computes to
1119-
the <a href="#preferred-size"><i>preferred size</i></a>. Otherwise, it
1120-
computes to itself, and is resolved to a length at used-value time by the
1121-
flexbox layout algorithm.
1122-
1123-
<p>A &lsquo;<a href="#ltflex"><code class=css>&lt;flex></code></a>&rsquo;
1124-
value is transitionable, by transitioning the <a
1157+
to &lsquo;<code class=css>0px</code>&rsquo;. If set to &lsquo;<code
1158+
class=property>auto</code>&rsquo;, the value of &lsquo;<code
1159+
class=property>width</code>&rsquo; or &lsquo;<code
1160+
class=property>height</code>&rsquo; (whichever is in parallel to main
1161+
axis) is used as preferred size.
1162+
1163+
<p>The keyword &lsquo;<a href="#flex-flow-none"><code
1164+
class=property>none</code></a>&rsquo; is equivalent to "0 0 auto".
1165+
1166+
<p class=note><b>Reviewers:</b> editors differ in preference for default
1167+
value of the preferred size. The current choice is default flexibility of
1168+
"1" and default preferred size of "0px". Earlier spec and two partial
1169+
implementations use defaults of "0" and "auto". These still have to be
1170+
defaults when &lsquo;<a href="#flex"><code
1171+
class=property>flex</code></a>&rsquo; property is not specified. <br>
1172+
The current defaults are chosen by consensus, but there has not been much
1173+
external input in support of either option. If you can share an opinion,
1174+
and/or use cases in support of either set of defaults, the editors would
1175+
appreciate it.
1176+
1177+
<p>A &lsquo;<code class=css>&lt;flex></code>&rsquo; value is
1178+
transitionable, by transitioning the <a
11251179
href="#preferred-size"><i>preferred size</i></a>, <a
11261180
href="#positive-flexibility"><i>positive flexibility</i></a>, and <a
11271181
href="#negative-flexibility"><i>negative flexibility</i></a>
1128-
independently. &lsquo;<a href="#ltflex"><code
1129-
class=css>&lt;flex></code></a>&rsquo; can also transition to and from a
1130-
&lt;length>, by treating the length as if it were a flexible length with a
1131-
positive and negative flexibility of zero and a preferred size of the
1132-
length.
1182+
independently. &lsquo;<code class=css>&lt;flex></code>&rsquo; can also
1183+
transition to and from a &lt;length>, by treating the length as if it were
1184+
a flexible length with a positive and negative flexibility of zero and a
1185+
preferred size of the length.
11331186

11341187
<p class=issue>Transitioning to/from a &lt;length> (or to/from a &lt;flex>
11351188
with 0 flexibility) doesn't work well if it's the only flexible item in
@@ -1138,11 +1191,11 @@ <h2 id=flexibility><span class=secno>4. </span> Flexibility: the
11381191
value that represents a percentage of the free space or something?
11391192

11401193
<div class=example>
1141-
<p>The &lsquo;<code class=css>flex()</code>&rsquo; notation allows
1142-
elements to respond directly to the available space, in ways that are
1143-
difficult or impossible in normal CSS. One common example is a page with
1144-
one segment intended to stay on screen, and another section which may be
1145-
long but which shouldn't scroll the page, like a chat room:</p>
1194+
<p>Flexibility allows elements to respond directly to the available space,
1195+
in ways that are difficult or impossible in normal CSS. One common
1196+
example is a page with one segment intended to stay on screen, and
1197+
another section which may be long but which shouldn't scroll the page,
1198+
like a chat room:</p>
11461199

11471200
<pre>
11481201
&lt;!DOCTYPE html>
@@ -1162,12 +1215,18 @@ <h2 id=flexibility><span class=secno>4. </span> Flexibility: the
11621215
&lt;/body>
11631216
&lt;style>
11641217
body { display:flexbox; flex-flow: column; }
1165-
#messages { height: flex(1); }
1218+
#messages { flex:1; }
11661219
&lt;/style></pre>
11671220

11681221
<p class=issue>Illustrate this example.</p>
11691222
</div>
11701223

1224+
<p class=issue>Currently there are no separate properties for pos-flex,
1225+
neg-flex or preferred size. If it doesn't change, there needs to be at
1226+
least CSS OM access to the separate values. Parsing space-separated list
1227+
is easier than functional notation, but figuring out the used value for
1228+
preferred size is still far from trivial.
1229+
11711230
<h2 id=alignment><span class=secno>5. </span> Alignment</h2>
11721231

11731232
<p>After a flexbox's contents have finished their flexing, they can be
@@ -1484,6 +1543,33 @@ <h3 id=flex-align><span class=secno>5.2. </span> Cross Axis Alignment: the
14841543
<a href="#cross-start"><i>cross-start</i></a> edge of the line.</p>
14851544
</dl>
14861545

1546+
<div class=issue>
1547+
<p>Finalize and define what happens to auto margin.
1548+
1549+
<p>Proposals:
1550+
1551+
<ul>
1552+
<li>cross-axis margins (align):
1553+
<ol>
1554+
<li>&lsquo;<code class=property>auto</code>&rsquo; is zero
1555+
1556+
<li>auto margins applied before alignment, map directly to alignment
1557+
values (start/end/center)
1558+
1559+
<li>auto margins applied before alignment, do safe align (flex-align
1560+
does &lsquo;<code class=css>true center</code>&rsquo; etc.)
1561+
</ol>
1562+
1563+
<li>main-axis margins (pack):
1564+
<ol>
1565+
<li>&lsquo;<code class=property>auto</code>&rsquo; is zero
1566+
1567+
<li>if there is positive extra space after flexing (and before pack),
1568+
distribute it equally to auto margins.
1569+
</ol>
1570+
</ul>
1571+
</div>
1572+
14871573
<div class=figure> <img height=377 src="images/flex-align.svg" width=508>
14881574
<p class=caption>An illustration of the five &lsquo;<a
14891575
href="#flex-align0"><code class=property>flex-align</code></a>&rsquo;
@@ -1566,7 +1652,7 @@ <h2 id=multi-line><span class=secno>6. </span> Multi-line Flexbox</h2>
15661652
width: 300px;
15671653
}
15681654
button {
1569-
width: flex(80px 1);
1655+
flex:80px 1;
15701656
}
15711657
&lt;style>
15721658

@@ -1612,7 +1698,7 @@ <h2 id=multi-line><span class=secno>6. </span> Multi-line Flexbox</h2>
16121698
width: 300px;
16131699
}
16141700
button {
1615-
width: flex(80px 1);
1701+
flex:80px 1;
16161702
max-width: 90px;
16171703
}</pre>
16181704

@@ -2584,6 +2670,22 @@ <h2 class=no-num id=property>Property index</h2>
25842670

25852671
<td>flexbox | inline-flexbox
25862672

2673+
<tr>
2674+
<th><a class=property href="#flex">flex</a>
2675+
2676+
<td>[[ &lt;pos-flex> &lt;neg-flex>? ]? &amp;&amp;
2677+
[&lt;preferred-size>]?] | none
2678+
2679+
<td>none
2680+
2681+
<td>flexbox items
2682+
2683+
<td>no
2684+
2685+
<td>specified value
2686+
2687+
<td>visual
2688+
25872689
<tr>
25882690
<th><a class=property href="#flex-align0">flex-align</a>
25892691

@@ -2774,8 +2876,7 @@ <h2 class=no-num id=index>Index</h2>
27742876
<li>fix min size violations, <a href="#fix-size-constraint-violations"
27752877
title="fix min size violations"><strong>7.</strong></a>
27762878

2777-
<li>&lt;flex>, <a href="#ltflex" title="&lt;flex>"><strong>4.</strong></a>
2778-
2879+
<li>flex, <a href="#flex" title=flex><strong>4.</strong></a>
27792880

27802881
<li>flex-align, <a href="#flex-align0"
27812882
title=flex-align><strong>5.2.</strong></a>

0 commit comments

Comments
 (0)