Last active
November 7, 2025 08:55
-
-
Save Kcko/03d098a060dffcb226ccbdbd3eb69969 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://jsbin.com/hegesunoyu/3/edit?html,css,output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| min-height: 100vh; | |
| min-height: 100dvh; | |
| padding: 1em; | |
| display: flex; | |
| align-items: start; /* end for fallbacks ..*/ | |
| justify-content: start; /* end for fallbacks ..*/ | |
| font-family: Poppins, 'SegoeUI', Tahoma, Geneva, sans-serif; | |
| } | |
| button { | |
| background: plum; | |
| padding: 0.7em 1.5em; | |
| border: none; | |
| font-weight: 500; | |
| border-radius: .3em; | |
| anchor-name: --test; | |
| } | |
| #menu { | |
| unset: all; | |
| width: max-content; | |
| border: 1px solid #ccc; | |
| padding: 1rem; | |
| background: #fff; | |
| border-radius: .3em; | |
| position: absolute; | |
| margin: 0; /* important !!! */ | |
| position-anchor: --test; | |
| top: anchor(bottom); | |
| left: anchor(left); | |
| position-try-fallbacks: --bottom-right, --bottom-left, --up-left, --up-right; | |
| } | |
| #menu:popover-open { | |
| display: grid; | |
| } | |
| @position-try --bottom-right { | |
| inset: unset; | |
| top: anchor(bottom); | |
| left: anchor(left); | |
| } | |
| @position-try --bottom-left { | |
| inset: unset; | |
| top: anchor(bottom); | |
| right: anchor(right); | |
| } | |
| @position-try --up-left { | |
| inset: unset; | |
| bottom: anchor(top); | |
| right: anchor(right); | |
| } | |
| @position-try --up-right { | |
| inset: unset; | |
| bottom: anchor(top); | |
| left: anchor(left); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <button popovertarget="menu">Menu button</button> | |
| <div id="menu" popover> | |
| <a href="">Item 1</a> | |
| <a href="">Another Item 2</a> | |
| <a href="">Very long long long Item 3</a> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment