Popover API Dropdown Menu with Anchor Positioning
An account button opens a dropdown menu beneath it. Clicking the button toggles the menu, clicking anywhere else or pressing Escape closes it, and the whole thing is two attributes and some CSS.
The menu is a popover, so the browser puts it in the top layer and handles open, close and light dismiss through the popovertarget attribute on the button. Anchor positioning ties it back to the button. The button declares an anchor-name, the menu points at it with position-anchor, and position-area drops it into the slot below, right aligned. The fade and slide are a transition on the :popover-open state, with @starting-style supplying the values it animates from.
Popover and anchor positioning are both in every current browser. In an older browser without anchor positioning the @supports fallback centers the menu as a small floating panel, so the control stays usable.