mirror of
https://github.com/hunvreus/basecoat.git
synced 2026-12-03 05:39:04 +00:00
Getting ready to clean up the package and release 0.2.0
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Anchor Positioning Test (Top, End)</title>
|
||||
<script type="module">
|
||||
if (!("anchorName" in document.documentElement.style)) {
|
||||
console.log("Loading CSS anchor positioning polyfill...");
|
||||
import("https://unpkg.com/@oddbird/css-anchor-positioning");
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
background: #222;
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 0.5em 1em;
|
||||
font-size: 1rem;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #888;
|
||||
background: #444;
|
||||
color: #eee;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
[popover] {
|
||||
border: 1px solid #888;
|
||||
border-radius: 6px;
|
||||
background: #333;
|
||||
color: #eee;
|
||||
padding: 1em;
|
||||
margin: 0;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* The core anchor positioning logic */
|
||||
#my-popover {
|
||||
position: absolute;
|
||||
inset: auto; /* Required to override default popover centering */
|
||||
bottom: anchor(top); /* Position bottom of popover to top of anchor */
|
||||
right: anchor(right); /* Align right edge of popover with right edge of anchor */
|
||||
margin-bottom: 8px; /* A little space between popover and button */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<button
|
||||
popovertarget="my-popover"
|
||||
id="my-anchor-button"
|
||||
style="anchor-name: --my-anchor;">
|
||||
Click Me
|
||||
</button>
|
||||
|
||||
<div
|
||||
popover
|
||||
id="my-popover"
|
||||
style="position-anchor: --my-anchor;">
|
||||
I should be anchored above the button, aligned to the right.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user