anchor-position-dynamic-004.html (1141B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#anchor-pos"> 3 <link rel="author" href="mailto:kojii@chromium.org"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/check-layout-th.js"></script> 7 <script src="support/test-common.js"></script> 8 <style> 9 .cb { 10 position: relative; 11 } 12 #anchor1 { 13 anchor-name: --a1; 14 margin-left: 15px; 15 width: 30px; 16 height: 20px; 17 background: red; 18 } 19 .after #anchor1 { 20 margin-left: 50px; 21 } 22 .target { 23 position: absolute; 24 left: anchor(--a1 left); 25 top: anchor(--a1 top); 26 right: anchor(--a1 right); 27 bottom: anchor(--a1 bottom); 28 background: lime; 29 } 30 </style> 31 <body> 32 <div class="cb"> 33 <div style="contain: strict; height: 50px"> 34 <div class="spacer" style="height: 10px"></div> 35 <div id="anchor1"></div> 36 </div> 37 38 <div class="target" 39 data-offset-x=50 data-offset-y=10 40 data-expected-width=30 data-expected-height=20></div> 41 </div> 42 <script type="module"> 43 document.body.classList.add('after'); 44 await checkLayoutForAnchorPos('.target'); 45 </script> 46 </body>