Skip to content

Commit b053ad6

Browse files
committed
[css-align] To match flexbox, *-self:stretch now allows shrinking.
1 parent d67aa09 commit b053ad6

File tree

2 files changed

+815
-1769
lines changed

2 files changed

+815
-1769
lines changed

css-align/Overview.bs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Content Distribution: the 'justify-content' and 'align-content' properties</h2>
435435
</pre>
436436

437437
Aligns the contents of the box as a whole along the box's inline/row/main axis.
438-
Values other than <dfn value for="justify-content, align-content">auto</dfn> are <a href="#alignment-values">defined above</a>.
438+
Values other than <dfn value for="justify-content, align-content">auto</dfn> are defined in [[#alignment-values]], above.
439439
If both a <<content-distribution>> and <<content-position>> are given,
440440
the <<content-position>> provides an explicit <a>fallback alignment</a>.
441441

@@ -526,14 +526,14 @@ Baseline Content-Alignment</h3>
526526
A <a>flex item</a> participates in first (last) <a>baseline content-alignment</a>
527527
in its flex line if
528528
its computed 'align-content' is ''baseline'' (''last-baseline'')
529-
and its computed 'align-self' is ''<content-distribution>/stretch'' or ''start'' (''end'').
529+
and its computed 'align-self' is ''align-self/stretch'' or ''start'' (''end'').
530530

531531
<dt>Grid Items:
532532
<dd>
533533
A <a>grid item</a> participates in first (last) <a>baseline content-alignment</a>
534534
in either its row or column (whichever matches its <a>inline axis</a>)
535535
if its computed 'align-content' is ''baseline'' (''last-baseline''),
536-
and its computed 'align-self' or 'justify-self' (whichever affects its <a>block axis</a>) is ''<content-distribution>/stretch'' or ''start'' (''end'').
536+
and its computed 'align-self' or 'justify-self' (whichever affects its <a>block axis</a>) is ''justify-self/stretch'' or ''start'' (''end'').
537537
</dl>
538538

539539
If a box spans multiple <a>shared alignment contexts</a>,
@@ -596,11 +596,22 @@ Inline/Main-Axis Alignment: the 'justify-self' property</h3>
596596
the box's outer edges are aligned within its <a>alignment container</a>
597597
<a href="#alignment-values">as described by its alignment value</a>.
598598

599-
The <dfn value for="justify-self">auto</dfn> keyword computes to
599+
The <dfn value for="justify-self, align-self">auto</dfn> keyword computes to
600600
itself on absolutely-positioned elements,
601601
and to the computed value of 'justify-items' on the parent
602602
(minus any ''legacy'' keywords) on all other boxes,
603603
or ''start'' if the box has no parent.
604+
Its behavior depends on the layout model, as described below.
605+
606+
When the box’s computed 'width'/'height' (as appropriate to the axis) is ''width/auto''
607+
and neither of its margins (in the appropriate axis) are ''margin/auto'',
608+
the <dfn for="justify-self, align-self">stretch</dfn> keyword
609+
sets the box’s used size to the length necessary to make its outer size
610+
as close to filling the <a>alignment container</a> as possible
611+
while still respecting the constraints imposed by 'min-height'/'min-width'/'max-height'/'max-width'.
612+
Unless otherwise specified, this value falls back to ''flex-start''.
613+
614+
All other values are as defined in [[#alignment-values]], above.
604615

605616
<hr>
606617

@@ -631,7 +642,7 @@ Inline/Main-Axis Alignment: the 'justify-self' property</h3>
631642

632643
When neither margin in this dimension is ''margin/auto''
633644
and neither offset property in this dimension is ''top/auto'',
634-
values other than ''<content-distribution>/stretch'' cause <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width">non-replaced absolutely-positioned boxes</a>
645+
values other than ''justify-self/stretch'' cause <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width">non-replaced absolutely-positioned boxes</a>
635646
to use shrink-to-fit sizing for calculating ''width/auto'' measures,
636647
and 'justify-self' dictates alignment as follows:
637648

@@ -646,7 +657,7 @@ Inline/Main-Axis Alignment: the 'justify-self' property</h3>
646657
and the used value of the offset properties are not adjusted to correct for the over-constraint.
647658

648659
The ''justify-self/auto'' keyword is equivalent to ''start'' on replaced absolutely-positioned boxes,
649-
and equivalent to ''<content-distribution>/stretch'' on all other absolutely-positioned boxes.
660+
and equivalent to ''justify-self/stretch'' on all other absolutely-positioned boxes.
650661
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)
651662

652663
<dt>Table Cells:
@@ -697,11 +708,9 @@ Block/Cross-Axis Alignment: the 'align-self' property</h3>
697708
the box's outer edges are aligned within its <a>alignment container</a>
698709
<a href="#alignment-values">as described by its alignment value</a>.
699710

700-
The <dfn value for="align-self">auto</dfn> keyword computes to
701-
itself on absolutely-positioned elements,
702-
and to the computed value of 'align-items' on the parent
703-
(minus any ''legacy'' keywords) on all other boxes,
704-
or ''start'' if the box has no parent.
711+
The ''align-self/auto'' and ''align-self/stretch'' keywords are as defined in [[#justify-self-property]].
712+
713+
All other values are as defined in [[#alignment-values]], above.
705714

706715
<hr>
707716

@@ -718,7 +727,7 @@ Block/Cross-Axis Alignment: the 'align-self' property</h3>
718727

719728
When neither margin in this dimension is ''margin/auto''
720729
and neither offset property in this dimension is ''top/auto'',
721-
values other than ''<content-distribution>/stretch'' cause <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height">non-replaced absolutely-positioned boxes</a>
730+
values other than ''align-self/stretch'' cause <a href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height">non-replaced absolutely-positioned boxes</a>
722731
to use shrink-to-fit sizing for calculating ''width/auto'' measures,
723732
and 'align-self' dictates alignment as follows:
724733

@@ -733,7 +742,7 @@ Block/Cross-Axis Alignment: the 'align-self' property</h3>
733742
and the used value of the offset properties are not adjusted to correct for the over-constraint.
734743

735744
The ''align-self/auto'' keyword is equivalent to ''start'' on replaced absolutely-positioned boxes,
736-
and equivalent to ''<content-distribution>/stretch'' on all other absolutely-positioned boxes.
745+
and equivalent to ''align-self/stretch'' on all other absolutely-positioned boxes.
737746
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)
738747

739748
<dt>Table Cells:
@@ -835,7 +844,7 @@ Inline/Main-Axis Alignment: the 'justify-items' property</h3>
835844
Otherwise, ''justify-items/auto'' computes to:
836845

837846
<ul>
838-
<li>''<content-distribution>/stretch'' for flex containers and grid containers
847+
<li>''justify-self/stretch'' for flex containers and grid containers
839848
<li>''start'' for everything else
840849
</ul>
841850

@@ -876,7 +885,7 @@ Block/Cross-Axis Alignment: the 'align-items' property</h3>
876885
Computes to:
877886

878887
<ul>
879-
<li>''<content-distribution>/stretch'' for flex containers and grid containers
888+
<li>''align-self/stretch'' for flex containers and grid containers
880889
<li>''start'' for everything else
881890
</ul>
882891
</dl>
@@ -1034,13 +1043,9 @@ Aligning Boxes by Baseline</h3>
10341043
<h2 id="changes">
10351044
Changes</h2>
10361045

1037-
Changes since the <a href="http://www.w3.org/TR/2013/WD-css3-align-20130514/">previous Working Draft</a> include:
1046+
Changes since the <a href="http://www.w3.org/TR/2014/WD-css-align-3-20141218/">previous Working Draft</a> include:
10381047

1039-
* Added ''last-baseline'' keyword.
1040-
* Improved details of baseline alignment.
1041-
* Changed handling of ''justify-self/auto''/''<content-distribution>/stretch'' for block-level and abspos elements in 'justify-self'/'align-self' to be more powerful and less confusing.
1042-
* Tightened up grammar combinations with <<overflow-position>> to be restricted to values that actually make sense.
1043-
* Various clarifications.
1048+
* Fixed handling of ''justify-self: stretch'' (and 'align-self') to allow shrinking, as defined in Flexbox.
10441049

10451050
<h2 class=no-num id="acknowledgments">
10461051
Acknowledgments</h2>

0 commit comments

Comments
 (0)