anchor-position-principal-box.html (852B)
1 <!DOCTYPE html> 2 <title>anchor-name only applies to elements which generate a principal box</title> 3 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#target-anchor-element"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <style> 7 body { margin-top: 0; } 8 #outer { 9 anchor-name: --anchor; 10 display: contents; 11 } 12 #inner { 13 anchor-name: --anchor; 14 } 15 #filler { 16 height: 100px; 17 } 18 #anchored { 19 position: absolute; 20 top: anchor(--anchor top); 21 } 22 </style> 23 <div id="outer"> 24 <div id="filler"></div> 25 <div id="inner"></div> 26 </div> 27 <div id="anchored"></div> 28 <script> 29 test(() => { 30 assert_equals(anchored.offsetTop, 100, "#anchored is positioned against #inner"); 31 }, "anchor-name should only apply to elements which generate a principal box"); 32 </script>