GifproGifpro

Anchor Away! CSS Anchor Positioning for Floating UI

CODE PREVIEW

エディタを読み込み中…
P

Prompt

Create a demo of CSS anchor positioning: a tooltip that follows an anchor element. Use a button as anchor, and a div positioned with anchor() and position-area/position-try. The tooltip should adjust if close to edges.

CSS Anchor Positioningを使うと、要素を別の要素(アンカー)に固定できます。position-anchorでアンカーを指定し、position-areaで配置位置を決めます。position-try-optionsプロパティで、ビューポートからはみ出す場合の代替位置を定義可能。このデモではツールチップがボタンに寄り添い、スペース不足で反対側に反転します。

Prompt Overview

CSS Anchor Positioning lets you attach an element to another element (anchor) using position-anchor and position-area. The position-try-options property defines fallback positions when the element would overflow the viewport. In this demo, the tooltip stays next to its anchor button and flips to the opposite side if space runs out.

Was this prompt helpful?

Comments

Comments appear after moderation

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
Homeヘルプ