Skip to content

Commit bf9c26a

Browse files
committed
[css-anchor-position-1] Add 'dialog' alignment value. w3c#10258
1 parent bb4f7d1 commit bf9c26a

File tree

1 file changed

+151
-101
lines changed

1 file changed

+151
-101
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 151 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -772,107 +772,6 @@ It serializes in the order given in the grammar (above),
772772
with the logical keywords serialized in their short forms
773773
(e.g. ''start start'' instead of ''block-start inline-start'').
774774

775-
<h4 id=position-area-alignment>
776-
Area-specific Default Alignment</h4>
777-
778-
Each <<position-area>> also implies a default [=self-alignment=],
779-
which will be used if the [=self-alignment property=] on the box
780-
is ''align-self/normal'':
781-
782-
* If the only the center track in an axis is selected,
783-
the default alignment in that axis is ''align-self/center''.
784-
* If all three tracks are selected,
785-
the default alignment in that axis is ''align-self/anchor-center''.
786-
* Otherwise, the default alignment in that axis
787-
is toward the non-specified side track:
788-
if it's specifying the “start” track of its axis,
789-
the default alignment in that axis is ''align-self/end''; etc.
790-
791-
<div class=example>
792-
For example, assuming an English-equivalent writing mode (horizontal-tb, ltr),
793-
then the value ''span-x-start top'' resolves to
794-
the ''position-area/start'' region of the vertical axis,
795-
and the ''position-area/start'' and ''position-area/center'' regions of the horizontal axis,
796-
so the default alignments will be ''align-self: end''
797-
(making the box's bottom [=margin edge=] flush with the bottom of the ''position-area/top'' region)
798-
and ''justify-self: end''
799-
(making the box's end-side [=margin edge=] flush with the end side of the ''position-area/span-start'' region).
800-
</div>
801-
802-
<div class=note>
803-
If the box overflows its [=inset-modified containing block=],
804-
but would still fit within its [=original containing block=],
805-
by default it will “shift” to stay within its [=original containing block=],
806-
even if that violates its normal alignment.
807-
See [[css-align-3#overflow-values]] for details.
808-
809-
This behavior makes it more likely
810-
that positioned boxes remain visible
811-
and within their intended bounds,
812-
even when their [=containing block=]
813-
ends up smaller than anticipated.
814-
815-
For example, a ''position-area: bottom span-right'' value
816-
lets the positioned box stretch
817-
from its anchor's left edge
818-
to its containing block's right edge,
819-
and left-aligns it in that space by default.
820-
But if the positioned box is larger than that space
821-
(such as if the anchor is very close to the right edge of the screen),
822-
it will shift leftwards to stay visible.
823-
</div>
824-
825-
826-
<!-- Big Text: a-center
827-
828-
███▌ ███▌ █████▌ █ █▌ █████▌ █████▌ ████▌
829-
▐█ ▐█ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
830-
█▌ █▌ █▌ █▌ ██▌ █▌ █▌ █▌ █▌ █▌
831-
█▌ █▌ ████▌ █▌ ████ █▌▐█ █▌ █▌ ████ ████▌
832-
█████▌ █▌ █▌ █▌ ██▌ █▌ █▌ █▌▐█
833-
█▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█
834-
█▌ █▌ ███▌ █████▌ █▌ ▐▌ █▌ █████▌ █▌ █▌
835-
-->
836-
837-
Centering on the Anchor: the ''anchor-center'' alignment value {#anchor-center}
838-
--------------------------------------------------------------
839-
840-
<pre class=propdef>
841-
Name: justify-self, align-self, justify-items, align-items
842-
New Values: anchor-center
843-
</pre>
844-
845-
The [=self-alignment properties=] allow an [=absolutely positioned box=]
846-
to align itself within the [=inset-modified containing block=].
847-
The existing values,
848-
plus carefully chosen [=inset properties=],
849-
are usually enough for useful alignment,
850-
but a common case for anchored positioning--
851-
centering over the [=anchor box=]--
852-
requires careful and somewhat complex set-up to achieve.
853-
854-
The new <dfn value for="justify-self, align-self, justify-items, align-items">anchor-center</dfn> value
855-
makes this case extremely simple:
856-
if the positioned box has a [=default anchor box=],
857-
then it is centered (insofar as possible)
858-
over the [=default anchor box=]
859-
in the relevant axis.
860-
861-
Additionally,
862-
any ''top/auto'' [=inset properties=] resolve to ''0''.
863-
864-
If the box is not [=absolutely positioned=],
865-
or does not have a [=default anchor box=],
866-
this value behaves as ''<self-position>/center''
867-
and has no additional effect on how [=inset properties=] resolve.
868-
869-
Note: When using ''anchor-center'', by default
870-
if the anchor is too close to the edge of the box's
871-
[=original containing block=],
872-
it will “shift” from being purely centered,
873-
in order to remain within the [=original containing block=].
874-
See [[css-align-3#overflow-values]] for more details.
875-
876775
<!-- Big Text: anchor()
877776

878777
███▌ █ █▌ ███▌ █▌ █▌ ███▌ ████▌ ██ ██
@@ -1389,6 +1288,157 @@ depending on some commonly needed layout conditions.
13891288
rather than <em>also</em> floating in a nonsensical location.
13901289
</div>
13911290

1291+
1292+
<!-- Big Text: Alignment
1293+
1294+
███▌ █▌ ████ ███▌ █ █▌ █ █ █████▌ █ █▌ █████▌
1295+
▐█ ▐█ █▌ ▐▌ █▌ █▌ █▌ █▌ ██ ██ █▌ █▌ █▌ █▌
1296+
█▌ █▌ █▌ ▐▌ █▌ ██▌ █▌ █▌█ █▐█ █▌ ██▌ █▌ █▌
1297+
█▌ █▌ █▌ ▐▌ █▌ ██▌ █▌▐█ █▌ █▌ █ ▐█ ████ █▌▐█ █▌ █▌
1298+
█████▌ █▌ ▐▌ █▌ █▌ █▌ ██▌ █▌ ▐█ █▌ █▌ ██▌ █▌
1299+
█▌ █▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ ▐█ █▌ █▌ █▌ █▌
1300+
█▌ █▌ █████ ████ ███▌ █▌ ▐▌ █▌ ▐█ █████▌ █▌ ▐▌ █▌
1301+
-->
1302+
1303+
Anchor-Based Alignment {#alignment}
1304+
======================
1305+
1306+
1307+
1308+
<h3 id=position-area-alignment>
1309+
Area-specific Default Alignment</h3>
1310+
1311+
When using 'position-area',
1312+
the behavior of the ''align-self/normal'' [=self-alignment=] value
1313+
changes depending on the <<position-area>> value,
1314+
to align the box towards the anchor:
1315+
1316+
* If the only the center track in an axis is selected,
1317+
the default alignment in that axis is ''align-self/center''.
1318+
* If all three tracks are selected,
1319+
the default alignment in that axis is ''align-self/anchor-center''.
1320+
* Otherwise, the default alignment in that axis
1321+
is toward the non-specified side track:
1322+
if it's specifying the “start” track of its axis,
1323+
the default alignment in that axis is ''align-self/end''; etc.
1324+
1325+
<div class=example>
1326+
For example, assuming an English-equivalent writing mode (horizontal-tb, ltr),
1327+
then the value ''span-x-start top'' resolves to
1328+
the ''position-area/start'' region of the vertical axis,
1329+
and the ''position-area/start'' and ''position-area/center'' regions of the horizontal axis,
1330+
so the default alignments will be ''align-self: end''
1331+
(making the box's bottom [=margin edge=] flush with the bottom of the ''position-area/top'' region)
1332+
and ''justify-self: end''
1333+
(making the box's end-side [=margin edge=] flush with the end side of the ''position-area/span-start'' region).
1334+
</div>
1335+
1336+
<div class=note>
1337+
If the box overflows its [=inset-modified containing block=],
1338+
but would still fit within its [=original containing block=],
1339+
by default it will “shift” to stay within its [=original containing block=],
1340+
even if that violates its normal alignment.
1341+
See [[css-align-3#overflow-values]] for details.
1342+
1343+
This behavior makes it more likely
1344+
that positioned boxes remain visible
1345+
and within their intended bounds,
1346+
even when their [=containing block=]
1347+
ends up smaller than anticipated.
1348+
1349+
For example, a ''position-area: bottom span-right'' value
1350+
lets the positioned box stretch
1351+
from its anchor's left edge
1352+
to its containing block's right edge,
1353+
and left-aligns it in that space by default.
1354+
But if the positioned box is larger than that space
1355+
(such as if the anchor is very close to the right edge of the screen),
1356+
it will shift leftwards to stay visible.
1357+
</div>
1358+
1359+
1360+
<!-- Big Text: a-center
1361+
1362+
███▌ ███▌ █████▌ █ █▌ █████▌ █████▌ ████▌
1363+
▐█ ▐█ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
1364+
█▌ █▌ █▌ █▌ ██▌ █▌ █▌ █▌ █▌ █▌
1365+
█▌ █▌ ████▌ █▌ ████ █▌▐█ █▌ █▌ ████ ████▌
1366+
█████▌ █▌ █▌ █▌ ██▌ █▌ █▌ █▌▐█
1367+
█▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█
1368+
█▌ █▌ ███▌ █████▌ █▌ ▐▌ █▌ █████▌ █▌ █▌
1369+
-->
1370+
1371+
Centering on the Anchor: the ''anchor-center'' alignment value {#anchor-center}
1372+
--------------------------------------------------------------
1373+
1374+
<pre class=propdef>
1375+
Name: justify-self, align-self, justify-items, align-items
1376+
New Values: anchor-center
1377+
</pre>
1378+
1379+
The [=self-alignment properties=] allow an [=absolutely positioned box=]
1380+
to align itself within the [=inset-modified containing block=].
1381+
The existing values,
1382+
plus carefully chosen [=inset properties=],
1383+
are usually enough for useful alignment,
1384+
but a common case for anchored positioning--
1385+
centering over the [=anchor box=]--
1386+
requires careful and somewhat complex set-up to achieve.
1387+
1388+
The new <dfn value for="justify-self, align-self, justify-items, align-items">anchor-center</dfn> value
1389+
makes this case extremely simple:
1390+
if the positioned box has a [=default anchor box=],
1391+
then it is centered (insofar as possible)
1392+
over the [=default anchor box=]
1393+
in the relevant axis.
1394+
1395+
Additionally,
1396+
any ''top/auto'' [=inset properties=] resolve to ''0''.
1397+
1398+
If the box is not [=absolutely positioned=],
1399+
or does not have a [=default anchor box=],
1400+
this value behaves as ''<self-position>/center''
1401+
and has no additional effect on how [=inset properties=] resolve.
1402+
1403+
Note: When using ''anchor-center'', by default
1404+
if the anchor is too close to the edge of the box's
1405+
[=original containing block=],
1406+
it will “shift” from being purely centered,
1407+
in order to remain within the [=original containing block=].
1408+
See [[css-align-3#overflow-values]] for more details.
1409+
1410+
<!-- Big Text: dialog
1411+
1412+
████▌ ████ ███▌ █▌ ███▌ ███▌
1413+
█▌ █▌ ▐▌ ▐█ ▐█ █▌ █▌ █▌ █▌ █▌
1414+
█▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌
1415+
█▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌ ██▌
1416+
█▌ █▌ ▐▌ █████▌ █▌ █▌ █▌ █▌ █▌
1417+
█▌ █▌ ▐▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
1418+
████▌ ████ █▌ █▌ █████ ███▌ ███▌
1419+
-->
1420+
1421+
Conditional Centering: the ''dialog'' alignment value {#conditional-centering}
1422+
-----------------------------------------------------
1423+
1424+
<pre class=propdef>
1425+
Name: justify-self, align-self, justify-items, align-items
1426+
New Values: dialog
1427+
</pre>
1428+
1429+
Dialog boxes are often displayed centered on the screen,
1430+
unless they are anchored to some other element.
1431+
1432+
The new <dfn value for="justify-self, align-self, justify-items, align-items">dialog</dfn> value
1433+
allows this behavior to be specified:
1434+
if the box is [=absolutely positioned=]
1435+
and its 'position-area' value is not ''position-area/none'',
1436+
it is aligned as per ''align-self/normal''
1437+
(see [[#position-area-alignment]]);
1438+
otherwise,
1439+
it is aligned as per ''align-self/center''.
1440+
1441+
13921442
<!-- Big Text: a-size()
13931443

13941444
███▌ ███▌ ████ █████▌ █████▌ ██ ██

0 commit comments

Comments
 (0)