CSS
:root {
--gap: 12px; /* アンカーとツールチップの隙間 */
--pad: 12px; /* 画面端の余白(最大幅計算に使う) */
--tip-max: 360px; /* ツールチップの最大幅 */
}
/* Popover は UA 既定で中央寄せ等が入るので、まずリセット */
.tip[popover] {
inset: auto; /* ←重要:popover既定のinsetを無効化 */
border: 0;
margin-inline: 8px;
padding: .9rem 1rem;
border-radius: 14px;
background-color: #666666ee;
color: #eaf0ff;
box-shadow: 0 18px 55px rgba(0,0,0,.55);
line-height: 1.45;
max-inline-size: min(var(--tip-max), calc(100vw - (var(--pad) * 2)));
overflow-wrap: anywhere;
}
@supports (anchor-name: --a) {
.tip[popover] {
position: fixed;
bottom: anchor(top);
justify-self: anchor-center;
margin-bottom: var(--gap);
/* はみ出したら上下左右を反転 */
position-try-fallbacks: flip-block flip-inline;
}
}
/* 非対応ブラウザ用(最低限) */
@supports not (anchor-name: --a) {
.tip[popover] { position: fixed; top: 12px; left: 12px; }
}
/* 以下、表示調整用 */
.board {
height: min(520px, calc(100vh - 2rem));
border: 1px solid rgba(255,255,255,.14);
border-radius: 28px;
position: relative;
background: #cccccc99;
}
.anchor-btn {
position: absolute;
padding: .7rem 1.1rem;
border-radius: 999px;
border: 1px solid rgba(255,255,255,.25);
background: #f5f5f5;
color: inherit;
cursor: pointer; /* クリックで開くので pointer に */
backdrop-filter: blur(8px);
}
.tl { top: 18px; left: 18px; }
.tr { top: 18px; right: 18px; }
.bl { bottom: 18px; left: 18px; }
.br { bottom: 18px; right: 18px; }