Anchored Auto Layout
npm

Hover or focus a box to measure it. Click its tag, or press ] and [, to pin one. Esc unpins.

    Legend
    • Anchor: a box with data-⚓️-name
    • Placed by anchors: out of flow
    • Gap from the anchor's edge, in px
    • Edges of the box you're inspecting

    Every tag, line and number here is itself placed by data-⚓️-* attributes. JS only measures.

    The tooltip that argues

    Click to cycle the requested side, or drag the button into a corner: data-⚓️-try="flip-all" lets the browser overrule the request, and @container anchored(fallback) queries report asked vs. got.

    Full page
    <header class="intro">
      <h1>The tooltip that argues</h1>
      <p>
        Click the button to ask for a side (<code>data-⚓️-side</code> cycles above → after → below → before).
        Drag it toward an edge: <code>data-⚓️-try="flip-all"</code> lets the browser overrule you when
        there's no room, and the tooltip reports <em>asked vs got</em> from an
        <code>@container anchored(fallback)</code> query. No JS measures the tooltip.
      </p>
      <div class="controls">
        <label class="xray"><input type="checkbox" id="xray"> X-ray</label>
        <span class="hint">Try the corners:</span>
        <button type="button" data-corner="top-left">↖</button>
        <button type="button" data-corner="top-right">↗</button>
        <button type="button" data-corner="center">•</button>
        <button type="button" data-corner="bottom-left">↙</button>
        <button type="button" data-corner="bottom-right">↘</button>
      </div>
    </header>
    
    <button class="subject" id="subject" type="button" data-corner="center"
            data-⚓️-name="--subject" aria-describedby="tip">
      <span class="grip" aria-hidden="true">⠿</span> <span>Ask<span class="long"> for a side</span></span>
    </button>
    
    <div class="tip" id="tip" popover="manual" role="tooltip"
         data-⚓️-to="--subject" data-⚓️-side="above" data-⚓️-align-x="center" data-⚓️-try="flip-all">
      <div class="card">
        <span class="arrow" aria-hidden="true"></span>
        <p class="argue"></p>
        <dl class="readout">
          <div><dt>asked</dt><dd class="asked"></dd></div>
          <div><dt>got</dt><dd class="got"></dd></div>
        </dl>
      </div>
    </div>

    data-⚓️-align-xdata-⚓️-namedata-⚓️-sidedata-⚓️-todata-⚓️-try

    Copied