Skip to content

Commit 7875737

Browse files
committed
[css-anchor-position] Switch inset-area to the new syntax. Specify that it modifies the containing block. #9862 #9598
1 parent 888736e commit 7875737

File tree

1 file changed

+106
-118
lines changed

1 file changed

+106
-118
lines changed

css-anchor-position-1/Overview.bs

+106-118
Original file line numberDiff line numberDiff line change
@@ -363,26 +363,13 @@ The 'inset-area' Property {#inset-area}
363363

364364
<pre class=propdef>
365365
Name: inset-area
366-
Value: none | <<inset-area-span>> [ / <<inset-area-span>> ]?
366+
Value: none | <<inset-area>>
367367
Initial: none
368368
Inherited: no
369369
Applies to: positioned elements with a [=default anchor element=]
370370
Animation type: TBD
371371
</pre>
372372

373-
<pre class=prod>
374-
<dfn>&lt;inset-area-span></dfn> =
375-
[ start || end || center ] |
376-
[ self-start || self-end || center ] |
377-
[ top || bottom || center ] |
378-
[ left || right || center ] |
379-
[ x-start || x-end || center ] |
380-
[ y-start || y-end || center ] |
381-
[ x-self-start || x-self-end || center ] |
382-
[ y-self-start || y-self-end || center ] |
383-
all
384-
</pre>
385-
386373
Most common use-cases of anchor positioning
387374
only need to worry about
388375
the edges of the positioned element's [=containing block=],
@@ -392,73 +379,94 @@ These lines can be thought of as defining a 3x3 grid;
392379
by specifying what area of this [=inset-area grid=] you want the positioned element to be in.
393380
Its syntax is:
394381

382+
<pre class=prod>
383+
<dfn>&lt;inset-area></dfn> = [
384+
[ left | center | right | center-left | center-right
385+
| x-start | x-end | center-x-start | center-x-end
386+
| x-self-start | x-self-end | center-x-self-start | center-x-self-end
387+
| all ]
388+
&&
389+
[ top | center | bottom | center-top | center-bottom
390+
| y-start | y-end | center-y-start | center-y-end
391+
| y-self-start | y-self-end | center-y-self-start | center-y-self-end
392+
| all ]
393+
|
394+
[ block-start | center | block-end | center-block-start | center-block-end
395+
| self-block-start | self-block-end | center-self-block-start | center-self-block-end
396+
| all ]
397+
&&
398+
[ inline-start | center | inline-end | center-inline-start | center-inline-end ]
399+
| self-inline-start | self-inline-end | center-self-inline-start | center-self-inline-end
400+
| all ]
401+
|
402+
[ start | center | end | center-start | center-end | all ]{1, 2}
403+
|
404+
[ self-start | center | self-end | center-self-start | center-self-end | all ]{1, 2}
405+
]
406+
</pre>
407+
395408
<dl dfn-for=inset-area dfn-type=value>
396409
: <dfn>none</dfn>
397410
:: The property has no effect.
398411

399-
: <dfn><<inset-area-span>></dfn>
400-
:: Behaves as <css>&lt;inset-area-span> / all</css>,
401-
filling the entire row/column of the grid
402-
indicated by the specified value.
403-
404-
: <dfn><<inset-area-span>> [ / <<inset-area-span>> ]?</dfn>
412+
: <dfn><<inset-area>></dfn>
405413
::
406414
If the element does not have a [=default anchor element=],
407415
or is not an [=absolutely-positioned=] element,
408416
this value has no effect.
409417

410-
Otherwise, the two spans define a rectangular region
411-
of the [=inset-area grid=],
412-
and have the following effects:
418+
Otherwise, the property selects a region of the [=inset-area grid=],
419+
and makes that the element's [=containing block=].
413420

414-
1. Any ''top/auto'' [=inset properties=] compute to
415-
the appropriate value
416-
to match the rectangular region.
417-
2. The ''align-self/normal'' value for the [=self-alignment properties=]
418-
behaves as either ''align-self/start'', ''align-self/end'',
419-
or ''align-self/anchor-center'',
420-
depending on the positioning of the region,
421-
to give a good default alignment for the positioned element.
421+
Note: This means that the [=inset properties=] specify offsets from the inset-area,
422+
and some property values,
423+
like ''max-height: 100%'',
424+
will be relative to the inset-area as well.
425+
426+
Additionally, the ''align-self/normal'' value for the [=self-alignment properties=]
427+
behaves as either ''align-self/start'', ''align-self/end'',
428+
or ''align-self/anchor-center'',
429+
depending on the positioning of the region,
430+
to give a good default alignment for the positioned element.
422431

423432
See [[#resolving-spans]] for details on both of these effects.
424433
If the two <<inset-area-span>>s do not define a valid region,
425434
this property is invalid.
435+
436+
Also, any ''top/auto'' [=inset properties=] resolve to ''0''.
426437
</dl>
427438

428439

429440
<h4 id=resolving-spans>
430441
Resolving <<inset-area-span>>s</h4>
431442

432-
The <dfn export>inset-area grid</dfn> is conceptually a 3x3 grid,
443+
The <dfn export>inset-area grid</dfn> is a 3x3 grid,
433444
composed of four grid lines in each axis.
434445
In order:
435446

436-
* the start edge of the element's [=containing block=]
437-
(aka the position referred to by ''top: 0px;''
438-
or whatever [=inset property=] corresponds to
439-
the start side of the containing block)
447+
* the start edge of the element's pre-modification [=containing block=],
448+
or the ''anchor-start()'' edge of the [=default anchor element=]
449+
if that is more [=start=]-ward
440450
* the ''anchor(start)'' edge of the [=default anchor element=]
441451
* the ''anchor(end)'' edge of the [=default anchor element=]
442-
* the end edge of the element's [=containing block=]
443-
(aka the position referred to by ''bottom: 0px'',
444-
or whatever [=inset property=] is opposite the first one)
452+
* the end edge of the element's pre-modification [=containing block=],
453+
or the ''anchor-start()'' edge fo the [=default anchor element=]
454+
if that is more [=end=]-ward.
445455

446-
Each <<inset-area-span>> specifies 1-3 regions in a given axis of that grid:
447-
the "start" region between the first two of those grid lines;
448-
the "center" region between the center two;
449-
and/or the "end region" between the last two.
450-
451-
<dl dfn-type=value dfn-for="inset-area, <inset-area-span>">
452-
: <dfn>all</dfn>
453-
:: All three regions of that axis,
454-
spanning the entire breadth of the containing block.
456+
An <<inset-area>> selects a region of this grid
457+
by specifying the rows and columns the region occupies,
458+
with each of the two keywords specifying one of them:
455459

460+
<dl dfn-type=value dfn-for="inset-area, <inset-area>">
456461
: <dfn>start</dfn>, <dfn>end</dfn>, <dfn>self-start</dfn>, <dfn>self-end</dfn>
457462
: <dfn>top</dfn>, <dfn>bottom</dfn>, <dfn>left</dfn>, <dfn>right</dfn>
458463
: <dfn>y-start</dfn>, <dfn>y-end</dfn>, <dfn>y-self-start</dfn>, <dfn>y-self-end</dfn>
459464
: <dfn>x-start</dfn>, <dfn>x-end</dfn>, <dfn>x-self-start</dfn>, <dfn>x-self-end</dfn>
465+
: <dfn>block-start</dfn>, <dfn>block-end</dfn>, <dfn>block-self-start</dfn>, <dfn>block-self-end</dfn>
466+
: <dfn>inline-start</dfn>, <dfn>inline-end</dfn>, <dfn>inline-self-start</dfn>, <dfn>inline-self-end</dfn>
460467
: <dfn>center</dfn>
461-
:: Any single keyword refers just to that region in the axis.
468+
:: The single corresponding row or column,
469+
depending on which axis this keyword is specifying.
462470

463471
Like in ''anchor()'',
464472
the plain logical keywords
@@ -467,99 +475,79 @@ and/or the "end region" between the last two.
467475
The ''inset-area/x-start''/etc determine their direction in the same way,
468476
but in the specified physical axis.
469477

470-
The "self" logical keyword
478+
The "self" logical keywords
471479
(''inset-area/self-start'', ''inset-area/x-self-end'', etc)
472480
are identical,
473481
but refer to the element's own writing mode.
474482

475-
: two keywords
476-
:: Refers to the area spanned by the two indicated regions.
483+
: <dfn>center-start</dfn>, <dfn>center-end</dfn>
484+
: <dfn>center-top</dfn>, <dfn>center-bottom</dfn>
485+
: <dfn>center-y-start</dfn>, <dfn>center-y-end</dfn>
486+
: <dfn>center-x-start</dfn>, <dfn>center-x-end</dfn>
487+
: <dfn>center-block-start</dfn>, <dfn>center-block-end</dfn>
488+
: <dfn>center-inline-start</dfn>, <dfn>center-inline-end</dfn>
489+
:: Two rows or columns,
490+
depending on which axis this keyword is specifying:
491+
the center row/column,
492+
and the row/column corresponding to the other half of the keyword
493+
as per the single-track keywords.
494+
495+
(For example, ''center-top'' spans the first two rows--
496+
the center row and the top row.)
477497

478-
(For example, ''top center'' spans the first two regions,
479-
but ''top bottom'' spans all three.)
480-
481-
: three keywords
482-
:: Refers to all three regions in the axis,
483-
identical to ''inset-area/all''
498+
: <dfn>all</dfn>
499+
:: All three rows or columns,
500+
depending on which axis this keyword is specifying.
484501
</dl>
485502

486-
Two spans referring to different axises
487-
thus define a rectangular region of the [=inset-area grid=].
488-
To determine the axises of two spans:
489-
490-
* If a span include a keyword that implies a physical axis
491-
(''inset-area/top'', ''inset-area/x-start'', etc),
492-
that's its axis.
493-
* If both of the spans include a physical keyword,
494-
they must refer to different axises.
495-
If not, then the two spans do not define a valid region.
496-
* If one of the spans include a physical keyword,
497-
and the other doesn't
498-
(it only includes ambiguous keywords,
499-
like ''inset-area/center'' or ''inset-area/start''),
500-
then the other span's axis is perpendicular to the physical one.
501-
* If neither span includes a physical keyword,
502-
the first refers to the [=block axis=]
503-
of the [=containing block=],
504-
and the second to the [=inline axis=].
505-
506-
If the spans define a valid region,
507-
they cause ''top/auto'' values for the [=inset properties=]
508-
to compute to values that will align the [=inset-modified containing block=]
509-
with the boundary of the defined region
510-
on that side.
511-
512-
Each span also implies a default alignment,
503+
Some keywords are ambiguous about what axis they refer to:
504+
''inset-area/center'', ''inset-area/all'',
505+
and the ''inset-area/start''/etc keywords that don't specify the block or inline axis explicitly.
506+
If the other keyword is unambiguous about its axis,
507+
then the ambiguous keyword is referring to the opposite axis.
508+
(For example, in ''block-start center'',
509+
the ''inset-area/center'' keyword is referring to the inline axis.)
510+
If both keywords are ambiguous, however,
511+
then the first refers to the block axis of the element's [=containing block=],
512+
and the second to the inline axis.
513+
(For example, ''all start'' is equivalent to ''all inline-start''.)
514+
515+
If only a single keyword is given,
516+
it behaves as if the second keyword is ''inset-area/all''
517+
if the given keyword is unambigous about its axis;
518+
otherwise, it behaves as if the given keyword was repeated.
519+
(For example, ''inset-area/top'' is equivalent to ''top all'',
520+
but ''inset-area/center'' is equivalent to ''center center''.)
521+
522+
<hr>
523+
524+
The <<inset-area>> also implies a default [=self-alignment=],
513525
which will be used if the [=self-alignment property=] on the element
514526
is ''align-self/normal'':
515527

516-
* If the span includes the center region,
528+
* If the inset area includes the center region in an axis
517529
the default alignment in that axis is ''align-self/anchor-center''.
518530
* Otherwise, it's the opposite of the region it specifies:
519-
if it's specifying the "start" region,
531+
if it's specifying the "start" region of its axis,
520532
the default alignment in that axis is ''align-self/end''; etc.
521533

522534
<div class=example>
523535
For example, assuming an English-equivalent writing mode (horizontal-tb, ltr),
524-
then the spans ''start center / top'' resolve to
536+
then the value ''center-x-start top'' resolves to
525537
the "start" region of the vertical axis,
526538
and the "start" and "center" regions of the horizontal axis,
527-
which will compute the [=inset properties=] to:
528-
529-
<pre highlight=css>
530-
/* "auto" computes to */
531-
top: 0px;
532-
bottom: anchor(start);
533-
left: 0px;
534-
right: anchor(end);
535-
536-
/* "normal" behaves as */
537-
align-self: end;
538-
justify-self: anchor-center;
539-
</pre>
540-
541-
In other words, its [=inset-modified containing block=]
542-
will be the pink region in the below diagram,
543-
and the positioned element
544-
will be centered against the top edge of the anchor.
539+
so the default alignments will be ''align-self: end;'' and ''justify-self: anchor-center;''
545540

546541
<figure>
547542
<img src="images/inset-area-example.png" width=400>
548543
<figcaption>
549-
An example of ''inset-area: start center / top'' positioning.
544+
An example of ''inset-area: center-x-start top'' positioning.
550545
</figcaption>
551546
</div>
552547

553-
Note: While the [=default anchor element=] can actually be positioned
554-
outside of the positioned element's [=containing block=],
555-
for the purpose of 'inset-area'&apos;s effects
556-
it's considered to be within the block,
557-
so the grid lines always have the described order.
558-
That is, even if the anchor is entirely below the containing block,
559-
a ''inset-area/bottom'' span will still cause the element to behave as
560-
''top: anchor(end); bottom: 0px; align-content: start;'';
561-
the rules for handling over-constrained [=inset properties=]
562-
will resolve the contradiction.
548+
Note: When the [=default anchor element=]
549+
is partially or completely outside of the pre-modified [=containing block=],
550+
some of the [=inset-area grid's=] rows or columns can be zero-sized.
563551

564552

565553
<!-- Big Text: anchor()
@@ -1222,7 +1210,7 @@ this property determines which [=position option=] to use.
12221210
keeping its position reasonably stable.
12231211
With ''always'' specified, however,
12241212
it will instead use the specified strategy
1225-
to select the "fallback" [=position overflow=],
1213+
to select the "fallback" [=position option=],
12261214
regardless of what was previously successful.
12271215

12281216
: <dfn>hide</dfn>

0 commit comments

Comments
 (0)