<main>
<!-- The id should match the anchor attribute -->
<button id="anchorA" popovertarget="tooltipA">Show tooltipA</button>
<button id="anchorB" popovertarget="tooltipB">Show tooltipB</button>
</main>
<dialog anchor="anchorA" id="tooltipA" popover>
<button popovertarget="tooltipA">Hide tooltipA</button>
</dialog>
<dialog anchor="anchorB" id="tooltipB" popover>
<button popovertarget="tooltipB">Hide tooltipB</button>
</dialog>
/* No longer needed
main [popovertarget] { anchor-name: --trigger; }
*/
[popover] {
margin: 0;
position: fixed;
/* No longer needed
position-anchor: --trigger;
*/
top: calc(anchor(bottom) + 10px);
justify-self: anchor-center;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.