Skip to content

Commit 5914bf0

Browse files
committed
[css-align] Finish baseline alignment.
1 parent 1902adb commit 5914bf0

2 files changed

Lines changed: 145 additions & 103 deletions

File tree

css-align/Overview.bs

Lines changed: 67 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Previous Version: http://www.w3.org/TR/2013/WD-css3-align-20130514/
1313
Previous Version: http://www.w3.org/TR/2012/WD-css3-align-20120612/
1414
Abstract: This module contains the features of <a href="http://www.w3.org/TR/CSS/">CSS</a> relating to the alignment of boxes within their containers in the various CSS box layout models: block layout, table layout, flex layout, and grid layout. (The alignment of text and inline-level content is defined in [[CSS3TEXT]] and [[CSS3LINE]].)
1515
!Issue Tracking: <a href="http://www.w3.org/Style/CSS/Tracker/products/39">http://www.w3.org/Style/CSS/Tracker/products/39</a>
16-
Link Defaults: selectors-3 (dfn) first formatted line, css-flexbox-1 (dfn) flex line, css-multicol-1 (dfn) multi-column element, css-fonts-3 (dfn) first available font, css21 (property) max-width/max-height/min-width/min-height
16+
Link Defaults: selectors-3 (dfn) first formatted line, css-flexbox-1 (dfn) flex line, css-multicol-1 (dfn) multi-column element, css-fonts-3 (dfn) first available font, css21 (property) max-width/max-height/min-width/min-height, css-writing-modes-3 (dfn) dominant baseline
1717
Ignored Terms: table cell, stretch
1818
At Risk: ''last-baseline''
1919
</pre>
@@ -83,19 +83,21 @@ Values</h3>
8383
<h2 id="overview">
8484
Overview of Alignment Properties</h2>
8585

86-
The alignment properties in CSS can be described along two axes:
86+
The <dfn>box alignment properties</dfn> in CSS are a set of 6 properties
87+
that control alignment of boxes within other boxes.
88+
They can be described along two axises:
8789

8890
<ul>
8991
<li>which dimension they apply to (inline vs. stacking), and
9092
<li>whether they control the position of the box within its parent, or the box's content within itself.
9193
</ul>
9294

93-
Note: This proposal uses the terms “justify” and “align” to distinguish
95+
Note: This specification uses the terms “justify” and “align” to distinguish
9496
between alignment in the inline and stacking dimensions, respectively.
9597
The choice is somewhat arbitrary, but having the two terms allows for
9698
a consistent naming scheme that works across all of CSS's layout models.
9799

98-
The following table summarizes the proposed alignment properties
100+
The following table summarizes the <a>box alignment properties</a>
99101
and the display types they can apply to.
100102

101103
<table class=data>
@@ -108,7 +110,6 @@ Overview of Alignment Properties</h2>
108110
<th>Axis
109111
<th>Aligns
110112
<th>Applies to
111-
</thead>
112113
<tbody>
113114
<tr>
114115
<th>'justify-content'
@@ -308,15 +309,15 @@ Baseline Alignment: the ''baseline'' and ''last-baseline'' keywords</h3>
308309
these values trigger <a>baseline content-alignment</a>,
309310
shifting the content of the box within the box,
310311
and may also affect the sizing of the box itself.
311-
See [#baseline-align-content].
312+
See [[#baseline-align-content]].
312313

313314
When specified for 'align-self'/'justify-self',
314315
these values trigger <a>baseline self-alignment</a>,
315316
shifting the entire box within its container,
316317
which may affect the sizing of its container.
317-
See [#baseline-align-self].
318+
See [[#baseline-align-self]].
318319

319-
If both <a>baseline content-alignment</a> <em>and</em> <a>baseline self-alignment</a> are specified in the same axis,
320+
If both <a>baseline content-alignment</a> <em>and</em> <a>baseline self-alignment</a> are specified in the same axis on the same box,
320321
only <a>baseline self-alignment</a> is honored in that axis;
321322
the content-alignment in that axis must be treated as ''self-start''.
322323

@@ -328,38 +329,6 @@ Baseline Alignment: the ''baseline'' and ''last-baseline'' keywords</h3>
328329
Note: The 'vertical-align' property will also need a ''first-baseline'' value
329330
because per CSS2.1 for inline blocks, ''baseline'' is equivalent to ''last-baseline''.
330331

331-
<hr>
332-
333-
A <dfn>baseline-sharing group</dfn>
334-
is composed of boxes that participate in baseline alignment together.
335-
This is possible only if they
336-
337-
<ul>
338-
<li>share an <a>alignment context</a> whose axis is parallel to their <a>inline axis</a>
339-
<li>either have the same <a>block flow direction</a> and <a>baseline alignment preference</a>,
340-
or have opposite <a>block flow direction</a> and opposite <a>baseline alignment preference</a>
341-
(in other words, the baselines that want to align are on the same side of the alignment context).
342-
</ul>
343-
344-
Boxes <dfn title="shared alignment context|alignment context">share an alignment context</dfn> along a particular axis when they are:
345-
346-
<ul>
347-
<li>table cells in the same row, along the table's row (inline) axis
348-
<li>table cells in the same column, along the table's column (block) axis
349-
<li>grid items in the same row, along the grid's row (inline) axis
350-
<li>grid items in the same column, along the grid's colum (block) axis
351-
<li>flex items in the same flex line, along the flex container's main axis
352-
</ul>
353-
354-
Boxes in a <a>baseline-sharing group</a> are aligned to each other
355-
using their <dfn>alignment baseline</dfn>.
356-
This is the dominant baseline associated with
357-
the box that generates their <a>shared alignment context</a>
358-
on the first (last, for ''last-baseline'' alignment) <a title="first formatted line">formatted line</a>.
359-
For example, in horizontal writing modes,
360-
specifying ''align-content: baseline'' on table cells in the same row
361-
will align the alphabetic baselines of their <a>first formatted lines</a>.
362-
363332

364333
<h3 id='distribution-values'>
365334
Distributed Alignment: the ''<content-distribution>/stretch'', ''space-between'', ''space-around'', and ''space-evenly'' keywords</h3>
@@ -585,6 +554,7 @@ Baseline Content-Alignment</h3>
585554
its <a>alignment subject</a> is aligned to the start (end) edge of its <a>alignment container</a>
586555
and the minimum necessary extra space is added between its start (end) edge and the <a>alignment subject</a>
587556
to match its <a>alignment baseline</a> in that axis up to that of its <a>baseline-sharing group</a>.
557+
See [[#align-by-baseline]].
588558
This increases the intrinsic size of the box.
589559

590560
<h3 id="overflow-scroll-position">
@@ -839,6 +809,7 @@ Baseline Self-Alignment</h3>
839809
its <a>alignment subject</a> is aligned to the start (end) edge of its <a>alignment container</a>
840810
and the minimum necessary extra space is added between its start (end) edge and the <a>alignment container</a>
841811
to match its <a>alignment baseline</a> in that axis up to that of its <a>baseline-sharing group</a>.
812+
See [[#align-by-baseline]].
842813
This may increase the intrinsic size contribution of the <a>alignment subject</a>.
843814

844815
<h2 id='default-alignment'>
@@ -928,6 +899,9 @@ Block/Cross-Axis Alignment: the 'align-items' property</h3>
928899

929900

930901
<h2 id='baseline-rules'>
902+
Baseline Alignment Details</h2>
903+
904+
<h3 id='baseline-export'>
931905
Determining the Baseline of a Box</h2>
932906

933907
The <dfn export title="first baselines|baselines of a box">first baselines</dfn> (and <dfn export>last baselines</dfn>) of a box
@@ -1005,7 +979,8 @@ Determining the Baseline of a Box</h2>
1005979
</dl>
1006980

1007981
To <dfn local-title=generate|generated>generate baselines</dfn> for a box from a single baseline,
1008-
use the baseline table from the font settings and <a>first available font</a> of that box.
982+
use the baseline table from the font settings and <a>first available font</a> of that box,
983+
and align that baseline set to the given single baseline.
1009984

1010985
To <dfn local-title=synthesize|synthesized>synthesize baselines</dfn> from a rectangle (or two parallel lines),
1011986
synthesize the alphabetic baseline from the lower line
@@ -1017,13 +992,58 @@ Determining the Baseline of a Box</h2>
1017992
Maybe these things are wrong?
1018993
CSS 2.1 is really weird about baseline alignment.
1019994

1020-
<div class="issue">
1021-
We're still working on handling multiple baseline types (alphabetc, central, etc.)
1022-
and rows with multiple baseline-sharing groups (e.g. contains both first and last-aligned cells, or contains opposing writing modes).
1023-
Consider this section to be Under Construction.
1024-
<img src="http://dev.w3.org/csswg/construction.gif" style="display: block; margin: 1em auto;">
1025-
</div>
995+
<h3 id='baseline-terms'>
996+
Baseline Alignment Terminology</h3>
997+
998+
A <dfn>baseline-sharing group</dfn>
999+
is composed of boxes that participate in baseline alignment together.
1000+
This is possible only if they
1001+
1002+
<ul>
1003+
<li>share an <a>alignment context</a> whose axis is parallel to their <a>inline axis</a>
1004+
<li>either have the same <a>block flow direction</a> and <a>baseline alignment preference</a>,
1005+
or have opposite <a>block flow direction</a> and opposite <a>baseline alignment preference</a>
1006+
(in other words, the baselines that want to align are on the same side of the alignment context).
1007+
</ul>
1008+
1009+
Boxes <dfn title="shared alignment context|alignment context">share an alignment context</dfn> along a particular axis when they are:
1010+
1011+
<ul>
1012+
<li>table cells in the same row, along the table's row (inline) axis
1013+
<li>table cells in the same column, along the table's column (block) axis
1014+
<li>grid items in the same row, along the grid's row (inline) axis
1015+
<li>grid items in the same column, along the grid's colum (block) axis
1016+
<li>flex items in the same flex line, along the flex container's main axis
1017+
</ul>
1018+
1019+
Boxes in a <a>baseline-sharing group</a> are aligned to each other
1020+
using their <dfn>alignment baseline</dfn>.
1021+
This is the dominant baseline associated with
1022+
the box that generates their <a>shared alignment context</a>
1023+
on the first (last, for ''last-baseline'' alignment) <a title="first formatted line">formatted line</a>.
1024+
For example, in horizontal writing modes,
1025+
specifying ''align-content: baseline'' on table cells in the same row
1026+
will align the alphabetic baselines of their <a>first formatted lines</a>.
1027+
1028+
<h3 id='align-by-baseline'>
1029+
Aligning Boxes by Baseline</h3>
1030+
1031+
Given a set of boxes and their baselines that all belong to a single <a>baseline-sharing group</a>,
1032+
the boxes are baseline-aligned as follows:
1033+
1034+
First, generate the alignment context's baseline table
1035+
from its <a>first available font</a>
1036+
and overlay also the mirror of this baseline table by aligning their central baselines.
1037+
These are the baseline grids to which the boxes will align.
1038+
1039+
Next, align all boxes by their specified <a>alignment baseline</a>
1040+
to the alignment context's baseline table
1041+
or its mirror, whichever matches its <a>line orientation</a>.
1042+
Unless otherwise specified (e.g. via the 'alignment-baseline' property),
1043+
the <a>alignment baseline</a> is the <a>dominant baseline</a> of the alignment context.
10261044

1045+
Position this <dfn>aligned subtree</dfn> within the alignment container
1046+
according to the rules of the <a>box alignment properties</a> in effect.
10271047

10281048
<h2 id="changes">
10291049
Changes</h2>

0 commit comments

Comments
 (0)