You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are flexboxes fill-available or fit-content by default?
1134
1134
Or are they really shrink-wrap, such that we need to adjust the main size here, now that we know the length of the longest line?
1135
1135
1136
-
<li>For each flexbox line,
1137
-
<ol>
1138
-
<li><i>Resolve the flexible lengths</i> of the items contained within it. All flexbox items now have a final main size. Update each item's hypothetical cross size based on this main size.</li>
1139
-
1140
-
<li>Calculate the leftover free-space by subtracting the sum of the
1141
-
margin-box main sizes of the items on the line from the main size of the flexbox's content box.</li>
1142
-
<li>Resolve ''auto'' margins on main axis:<ol>
1143
-
<li>If leftover free-space is positive and any items on this
1144
-
line have at least one main-axis margin set to ''auto'',
1145
-
distribute the leftover free-space equally to these margins.</li>
1146
-
<li>Otherwise, any main-axis ''auto''
1147
-
margins on items in this line are set to zero.</li>
1148
-
</ol>
1149
-
</li>
1150
-
<li>
1151
-
Align the items along the main axis per 'flex-pack'.
1152
-
</li>
1153
-
</ol>
1154
-
</li>
1136
+
<li>
1137
+
<ahref='#resolve-flexible-lengths'>Resolve the flexible lengths</a> of all the flexbox items to find their used main size.
1138
+
Determine their hypothetical cross size from this main size.
1139
+
1140
+
<li>
1141
+
Distribute any remaining free space.
1142
+
For each flexbox line:
1155
1143
1156
-
<li>Calculate the cross size of each flexbox line. For each flexbox
1157
-
line:
1158
1144
<ol>
1159
-
<li>If the flexbox is single-line and has a definite cross size, the single flexbox line's cross size is the cross size of the flexbox's content box. End this step of the algorithm.</li>
1145
+
<li>
1146
+
If the remaining free space is positive
1147
+
and at least one main-axis margin on this line is ''auto'',
1148
+
distribute the free space equally among these margins.
1149
+
Otherwise, set all ''auto'' margins to zero.
1150
+
1151
+
<li>
1152
+
Align the items along the main axis per 'flex-pack'.
1153
+
</ol>
1160
1154
1161
-
<li>If main axis is parallel to inline axis, collect all the flexbox items with a 'flex-item-align' of 'baseline'. Find the maximum of the distances from their baseline to the cross-start edge of their margin box, and the maximum of the distances from their baseline to the cross-end edge of their margin box. Sum these two values.</li>
1155
+
<li>
1156
+
Calculate the cross size of each flexbox line.
1157
+
For each flexbox line:
1158
+
1159
+
<ol>
1160
+
<li>
1161
+
Collect all the flexbox items whose inline axis is parallel to the main axis
1162
+
and whose 'flex-item-align' is ''baseline''.
1163
+
Find the largest of the distances between each item's baseline and its hypothetical outer cross-start edge,
1164
+
and the largest of the distances between each item's baseline and its hypothetical outer cross-end edge,
1165
+
and sum these two values.
1162
1166
1163
-
<li>For remaining flexbox items, find the maximum of the cross sizes of their margin boxes.
1167
+
<li>
1168
+
Among all the items not collected by the previous step,
1169
+
find the largest hypothetical outer cross-size.
1164
1170
1165
-
<li>The cross size of the flexbox line is the larger of the numbers found in the previous two steps.</li>
1166
-
<li>If the flexbox is multi-line, has a definite cross size,
1167
-
'flex-line-pack' is set to ''stretch'' and sum of cross size of
1168
-
all lines is less than cross size of content box, increase cross
1169
-
size of each line by equal amount to exactly match the cross
1170
-
size of content box.</li>
1171
+
<li>
1172
+
The cross-size of the flexbox line is the larger of the numbers found in the previous two steps.
1171
1173
</ol>
1172
-
</li>
1173
1174
1174
-
<li>If the flexbox doesn't have a definite cross size, the cross size of its content box is the sum of the cross sizes of all of its lines.</li>
1175
+
<p>
1176
+
If the flexbox has a <i>definite</i> cross size,
1177
+
'flex-line-pack' is ''stretch'',
1178
+
and the sum of the flexbox lines' cross sizes is less than the flexbox's inner cross size,
1179
+
increase the cross size of each flexbox line by equal amounts
1180
+
such that the sum of their cross sizes exactly equals the flexbox's inner cross size.
1175
1181
1176
1182
<li>
1177
-
<p>Determine the final cross size of each flexbox item.
1178
-
<ol>
1179
-
<li>If a flexbox item has ''flex-item-align:stretch'' and its
1180
-
preferred cross size is ''auto'' and its margin-box cross size is
1181
-
smaller than cross-size of its flexbox line, its final cross size is
1182
-
set so that its margin-box cross size is equal to cross-size of its flexbox line.
1183
-
<li>For all other flexbox items, its final cross size is its hypothetical cross size.
1184
-
</li>
1185
-
<li>If the resulting cross size of any item conflicts with 'min-width', 'max-width', 'min-height' or
1186
-
'max-height', correct the result to comply with the restrictions.</li>
1187
-
</ol>
1188
-
</li>
1189
-
<li>Resolve ''auto'' margins on cross axis. For each flexbox item, if its
1190
-
margin box cross size is smaller than cross size of its line and it has
1191
-
any margins in cross direction set to ''auto'', distribute the difference
1192
-
equally to the auto margins. </li>
1193
-
<li>For each flexbox line, align the flexbox items per 'flex-item-align'.</li>
1194
-
1195
-
<li>Align the flexbox lines per 'flex-line-pack'. The leftover free-space is calculated by subtracting the sum of the flexbox line's cross sizes from the cross size of the flexbox's content box.</li>
1196
-
<li>Layout all items again in their final size and position.
1197
-
Implementations can determine when this step is needed and how it can be
1198
-
optimized, but for precise results it has to be assumed that this step
1199
-
is performed.</li>
1183
+
Resolve cross axis ''auto'' margins.
1184
+
If a flexbox item has ''auto'' cross axis margins,
1185
+
and its outer cross size
1186
+
(treating those ''auto'' margins as zero)
1187
+
is less than the cross size of its flexbox line,
1188
+
distribute the difference in those sizes equally
1189
+
to the ''auto'' margins.
1190
+
1191
+
<li>
1192
+
Determine the used cross size of each flexbox item.
1193
+
1194
+
<p>
1195
+
If a flexbox item has ''flex-item-align: stretch''
1196
+
and its cross size property is ''auto'',
1197
+
the used outer cross size is the cross size of its flexbox line,
1198
+
clamped by its min and max cross size properties.
1199
+
1200
+
<p>
1201
+
Otherwise,
1202
+
the used cross size is the item's hypothetical cross size.
1203
+
1204
+
<li>
1205
+
Align all flexbox items along the cross axis per 'flex-item-align'.
1206
+
1207
+
<li>
1208
+
Determine the flexbox's used cross size.
1209
+
1210
+
<ul>
1211
+
<li>
1212
+
If the cross size property is a <i>definite</i> size,
1213
+
use that.
1214
+
1215
+
<li>
1216
+
Otherwise,
1217
+
use the sum of the flexbox lines' cross sizes.
1218
+
</ul>
1219
+
1220
+
<li>
1221
+
Align all flexbox lines per 'flex-line-pack'.
1200
1222
</ol>
1201
1223
1202
-
<p>To <dfn>resolve the flexible lengths</dfn> of the items within a flexbox line:</p>
1224
+
<h3id='resolve-flexible-lengths'>
1225
+
Resolving Flexible Lengths</h3>
1226
+
1227
+
<p>
1228
+
To resolve the flexible lengths of the items within a flexbox line:
0 commit comments