Skip to content

Commit baadeac

Browse files
committed
Generalized vertical alignment to all writing modes.
1 parent e1002b5 commit baadeac

1 file changed

Lines changed: 93 additions & 37 deletions

File tree

css3-layout/new2.src.html

Lines changed: 93 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,14 @@ <h3 id=dependencies>Dependencies on other modules</h3>
590590
<dfn>display</dfn> and <dfn>overflow</dfn>
591591

592592
<li><cite>CSS text layout</cite> [[!CSS3-WRITING-MODE]] &ndash;
593-
properties <dfn>direction</dfn> and <dfn>writing-mode</dfn>
593+
defines <dfn>block flow direction</dfn> and the
594+
properties <dfn>direction</dfn> and <dfn>writing-mode</dfn>. The
595+
latter defines when an element has a <dfn>vertical writing mode</dfn>
596+
(text lines are vertical) or a <dfn>horizontal writing mode</dfn>
597+
(text lines are horizontal). For brevity, we refer to the former as
598+
a <dfn title="vertical|vertical element" >vertical element</dfn> and
599+
to the latter as a <dfn title="horizontal|horizontal element"
600+
>horizontal element.</dfn>
594601

595602
<li><cite>CSS positioning</cite> [[!CSS3POS]] &ndash; properties
596603
<dfn>z-index</dfn>, <dfn>position</dfn>, <dfn>top</dfn>,
@@ -1179,7 +1186,7 @@ <h3 id=grid-shorthand> The 'grid' shorthand property</h3>
11791186

11801187
<!--=================================================================-->
11811188

1182-
<h3 id=default> Default slots</h3>
1189+
<h3 id=default>Default slots</h3>
11831190

11841191
<p>Every <span>grid element</span> has a <dfn>default slot.</dfn> If
11851192
there is an asterisk (“*”) in the template, then that slot is the
@@ -1230,7 +1237,7 @@ <h3 id=default> Default slots</h3>
12301237

12311238
<!--=================================================================-->
12321239

1233-
<h3 id=slot-sizes> Calculating the size of the grid</h3>
1240+
<h3 id=slot-sizes>Calculating the size of the grid</h3>
12341241

12351242
<p>For the purpose of the calculations below, each slot (letter or
12361243
“*”) in a grid has four dimensions associated with it,
@@ -1328,11 +1335,11 @@ <h3 id=slot-sizes> Calculating the size of the grid</h3>
13281335
contents of the column (i.e., the row heights are specified with
13291336
only <var>&lt;length&gt;</var> values,
13301337
'*', <var>&lt;fraction&gt;</var> values, or any combination of those),
1331-
then <var>MINH</var> is infinite.
1338+
then <var>PREFH</var> is infinite.
13321339

13331340
<li>Otherwise, if the slot is <em>horizontal,</em>
13341341
then <var>PREFH</var> is the <em>block dimension</em> of the slot,
1335-
plus its vertical padding, border and margin
1342+
plus its vertical padding, border and margin.
13361343

13371344
<li>Otherwise, if the slot spans at least one row whose height is
13381345
specified as ''max-content'' (or 'minmax()' with a first argument of
@@ -1444,7 +1451,9 @@ <h3 id=slot-sizes> Calculating the size of the grid</h3>
14441451
<li>
14451452
<p>Each row that contains slots that span only one row and no slots
14461453
that span more than one row, must not be higher than the
1447-
largest <var>PREFH</var> of all slots in the row.
1454+
largest <var>PREFH</var> of all slots in the row plus the amount
1455+
needed to vertically align the <span>horizontal</span> slots that have
1456+
a 'vertical-align' of ''baseline''.
14481457

14491458
<div class=example>
14501459
<p>For example, the second row in this grid
@@ -1462,7 +1471,9 @@ <h3 id=slot-sizes> Calculating the size of the grid</h3>
14621471
<li>
14631472
<p>Each column that contains slots that span only one column and no
14641473
slots that span more than one column, must not be wider than the
1465-
largest <var>PREFW</var> of all slots in the column.
1474+
largest <var>PREFW</var> of all slots in the column plus the amount
1475+
needed to align the <span>vertical</span> slots that have a
1476+
'vertical-align' of ''baseline''.
14661477

14671478
<div class=example>
14681479
<p>For example, in this grid
@@ -1644,7 +1655,7 @@ <h3 id=slot-sizes> Calculating the size of the grid</h3>
16441655

16451656
<!--=================================================================-->
16461657

1647-
<h2 id=positioning> Putting content into a grid element</h2>
1658+
<h2 id=positioning>Putting content into a grid element</h2>
16481659

16491660
<p><em>This section until the next subsection is not normative.</em>
16501661

@@ -1662,7 +1673,7 @@ <h2 id=positioning> Putting content into a grid element</h2>
16621673

16631674
<!--=================================================================-->
16641675

1665-
<h3 id=flow> Flowing content into slots: 'flow'</h3>
1676+
<h3 id=flow>Flowing content into slots: 'flow'</h3>
16661677

16671678
<p>The 'flow' property adds an element to a slot.
16681679

@@ -2113,7 +2124,8 @@ <h3>Absolute positioning using a grid: 'grid-position-x' and
21132124

21142125
<dt><var>&lt;grid-line&gt;</var>
21152126
<dd>
2116-
Equivalent to '<var>&lt;grid-line&gt;</var> + 1'.
2127+
Equivalent to '<var>&lt;grid-line&gt;</var> + 1' (i.e., a position and
2128+
a span of 1).
21172129

21182130
<dt><var>&lt;identifier&gt;</var> - <var>&lt;identifier&gt;</var>
21192131
<dd>
@@ -2166,7 +2178,7 @@ <h3>Absolute positioning using a grid: 'grid-position-x' and
21662178
</pre>
21672179

21682180
<p>mean that any P spans the same rows as slot a and spans the same
2169-
columns as slot c. In this case, that means it coincides with slot b.
2181+
columns as slot d. In this case, that means it coincides with slot b.
21702182
All of the following are thus equivalent:
21712183

21722184
<pre>
@@ -2319,10 +2331,10 @@ <h3 id=grid-position> The 'grid-position' shorthand property</h3>
23192331

23202332
<!--=================================================================-->
23212333

2322-
<h2 id=slot-pseudo> Styling slots: the ''::slot()'' pseudo-element</h2>
2334+
<h2 id=slot-pseudo>Styling slots: the ''::slot()'' pseudo-element</h2>
23232335

2324-
<p>The slots of a <em>template element</em> can be individually
2325-
addressed with the <dfn>''slot()'' pseudo-element.</dfn>
2336+
<p>The slots of a <em>grid element</em> can be individually addressed
2337+
with the <dfn>''::slot()'' pseudo-element.</dfn>
23262338

23272339
<div class=example>
23282340
<p>For example, the following sets the background and vertical
@@ -2419,45 +2431,84 @@ <h2>Rendering of grid elements</h2>
24192431
<h3 id=vertical-alignment>Vertical alignment of the contents of slots</h3>
24202432

24212433
<p>The 'vertical-align' property of a '::slot()' pseudo-element can be
2422-
used to align elements vertically in a slot. The effect is as if the
2434+
used to align elements vertically in a slot (or horizontally, if the
2435+
slot is <span>vertical</span>). The effect is as if the
24232436
<em title="anonymous block of a slot">hypothetical anonymous block</em>
2424-
that contains the slot's contents is positioned as follows:
2437+
that contains the slot's contents is positioned as defined below.
2438+
2439+
<p>For the purpose of this section we define the <dfn>tail edge</dfn>
2440+
and <dfn>head edge</dfn> of a box as a writing-mode-dependent edge as
2441+
follows:
2442+
2443+
<table class=equiv-table>
2444+
<thead>
2445+
<tr><th>Value of 'writing-mode' <th>Meaning of “head” <th>Meaning of “tail”
2446+
<tbody>
2447+
<tr><th>''horizontal-tb'' <td>top <td>bottom
2448+
<tr><th>''vertical-rl'' <td>right <td>left
2449+
<tr><th>''vertical-lr'' <td>left <td>right
2450+
</table>
2451+
2452+
<p>E.g., if a box is <span>horizontal,</span> “head edge” means the
2453+
top edge.
24252454

24262455
<dl>
24272456
<dt>bottom
24282457
<dd>
2429-
The content of the slot is aligned to the bottom of the slot: the
2430-
bottom margin edge of the anonymous block coincides with the bottom of
2431-
the slot.
2458+
The content of the slot is aligned to the <span>tail edge</span> of
2459+
the slot: the tail margin edge of the anonymous block coincides with
2460+
the tail margin edge of the slot.
24322461

24332462
<dt>middle
24342463
<dd>
2435-
The content of the slot is vertically centered in the slot: the
2436-
distance between the top margin edge of the anonymous block and the top
2437-
of the slot is equal to the distance between the bottom margin edge of
2438-
the anonymous block and the bottom of the slot. <span class=note>(Note
2439-
that if the content overflows the slot, it will overflow both at the
2440-
top and at the bottom.)</span>
2464+
The content of the slot is centered in the slot: the distance between
2465+
the <span title="head edge">head</span> margin edge of the anonymous
2466+
block and the <span title="head edge">head</span> margin edge of the
2467+
slot is equal to the distance between the <span title="tail
2468+
edge">tail</span> margin edge of the anonymous block and
2469+
the <span title="tail edge">tail</span> margin edge of the
2470+
slot. <span class=note>(Note that if the content overflows the slot,
2471+
it will overflow at both edges.)</span>
24412472

24422473
<dt>baseline
24432474
<dd>
2444-
The anonymous block that encloses the content is placed as high as
2445-
possible under two constraints:
2475+
The anonymous block that encloses the content is placed as far as
2476+
possible in the direction against the <em>block flow direction</em>
2477+
under two constraints:
24462478

24472479
<ol>
2448-
<li>The top margin edge of the anonymous block may not be higher than
2449-
the top edge of the slot.
2450-
2451-
<li>The topmost baseline in the content may not be higher than the
2452-
topmost baseline of content in any other slot in the same row that also
2453-
has 'vertical-align: baseline'. Baselines of content inside floats are
2454-
not taken into account. Slots that span several rows are considered to
2455-
occur in their topmost row.
2480+
<li>The <span title="head edge">head</span> margin edge of the
2481+
anonymous block may not be beyond the <span title="head edge">head</span>
2482+
margin edge of the slot.
2483+
2484+
<li>If the content has a relevant first line (see below), then the
2485+
baseline of that line must align with the baselines of the relevant
2486+
first lines in all other slots with the same 'writing-mode' and the
2487+
same 'vertical-align' in the same row (if the slot
2488+
is <span>horizontal</span>) or same column (if the slot
2489+
is <span>vertical</span>). A slot has a relevant first line, if the
2490+
content has a first line (ignoring any lines inside floats) and that
2491+
first line has the same 'writing-mode' as the slot itself.
24562492
</ol>
2493+
2494+
<p class=note>For example, for a <span>horizontal</span> slot, this
2495+
means that the first baseline must be aligned with the first baselines
2496+
of all other horizontal slots in the row that also have
2497+
'vertical-align: baseline'.
2498+
2499+
<dt><var>&lt;percentage&gt;</var>
2500+
<dd>
2501+
''0%'' means the same as ''bottom'', ''100%'' means the same as
2502+
''top'', other values are linear interpolations of these. Negative
2503+
values and values over 100% are interpreted as 0% and 100%
2504+
respectively.
2505+
2506+
<p class=note>Note that 100% minus the percentage corresponds to the
2507+
initial position of the scrolling mechanism (if any) in case the
2508+
content overflows.
24572509
</dl>
24582510

2459-
<p>For all other values, the content is top aligned: the top margin
2460-
edge of the anonymous box coincides with the top edge of the slot.
2511+
<p>For all other values, the content is aligned as for ''baseline''.
24612512

24622513
<!--=================================================================-->
24632514

@@ -3965,6 +4016,11 @@ <h2 id=changes>Changes</h2>
39654016
<li>References to 'page-break-*' properties and to [[CSS3PAGE]] have
39664017
been replaced with references to 'break-*' properties and the new
39674018
[[CSS3-BREAK]] module.
4019+
4020+
<li>Now allows <var>&lt;percentage&gt;</var> on 'vertical-align'.
4021+
4022+
<li>Generalized the text for 'vertical-align' to apply to all writing
4023+
modes.
39684024
</ul>
39694025

39704026
<!--=================================================================-->

0 commit comments

Comments
 (0)