Skip to content

Commit f786720

Browse files
committed
[css-anchor-position] Simplify introductory example
1 parent d61571c commit f786720

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,18 @@ This can be done with the following CSS:
8282
referring to the --tooltip anchor. */
8383
anchor-default: --tooltip;
8484

85-
/* Align the tooltip's bottom to the top of the anchor,
86-
but automatically swap if this overflows the window
87-
to the tooltip's top aligns to the anchor's bottom
88-
instead. */
89-
bottom: anchor(outside);
85+
/* Align the tooltip's bottom to the top of the anchor;
86+
this also defaults to horizontally center-aligning
87+
the tooltip and the anchor (in horizontal writing modes). */
88+
inset-area: block-start;
9089

91-
/* Set up a 300px-wide area, centered on the anchor.
92-
If centering would put part of it off-screen,
93-
instead clamp it to remain on-screen. */
94-
left: clamp(0px, anchor(center) - 150px, 100% - 300px);
95-
right: clamp(0px, anchor(center) - 150px, 100% - 300px);
96-
max-width: 300px;
90+
/* Automatically swap if this overflows the window
91+
so the tooltip's top aligns to the anchor's bottom
92+
instead. */
93+
position-try: flip-block;
9794

98-
/* Center the tooltip in that area. */
99-
justify-self: center;
95+
/* Prevent getting too wide */
96+
max-inline-size: 20em;
10097
}
10198
</pre>
10299
</div>

0 commit comments

Comments
 (0)