diff --git a/.gitignore b/.gitignore index 7709bf62..1d849e9f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ lib-cov coverage *.lcov playwright-report +test-results # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt diff --git a/index.html b/index.html index 7fd4e44f..2acdddd0 100644 --- a/index.html +++ b/index.html @@ -47,13 +47,20 @@ bottom: anchor(--my-anchor-style-tag start); right: anchor(--my-anchor-style-tag left); } + + #anchor-manual .anchor { + inline-size: fit-content; + margin: 3rem auto; + } @@ -1003,6 +1120,86 @@
<style>
)
+ <link>
)
+ + With polyfill applied: Target 1, 2, and 3 are positioned at Anchor’s + top-left, top-right, and bottom-right corners respectively. +
+<style id="my-style-manual-anchor">
+ #my-anchor-manual {
+ anchor-name: --my-anchor-manual;
+ }
+</style>
+<style id="my-style-manual-style-el">
+ #my-target-manual-style-el {
+ position: absolute;
+ bottom: anchor(--my-anchor-manual top);
+ right: anchor(--my-anchor-manual left);
+ }
+</style>
+<link rel="stylesheet" href="/anchor-manual.css" id="my-style-manual-link-el" />
+<!--
+CSS inside the anchor-manual.css file:
+
+#my-target-manual-link-el {
+ position: absolute;
+ bottom: anchor(--my-anchor-manual top);
+ left: anchor(--my-anchor-manual right);
+}
+-->
+
+<div id="my-anchor-manual" class="anchor">...</div>
+<div id="my-target-manual-style-el" class="target">...</div>
+<div id="my-target-manual-link-el" class="target">...</div>
+<div id="my-target-manual-inline-style" class="target"
+ style="position: absolute;
+ top: anchor(--my-anchor-manual bottom);
+ left: anchor(--my-anchor-manual right);"
+>...</div>
+
+<script>
+ polyfill({
+ elements: [
+ // The <style> element for anchor
+ document.getElementById('my-style-manual-anchor'),
+ // The <style> element
+ document.getElementById('my-style-manual-style-el'),
+ // The <link> element
+ document.getElementById('my-style-manual-link-el'),
+ // The target element with inline styles
+ document.getElementById('my-target-manual-inline-style'),
+ ],
+ });
+</script>