| <!DOCTYPE html> |
| <title>CSS Anchor Positioning Test: Dynamically change the anchor-center position</title> |
| <link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-center"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <style> |
| #cb { |
| position: relative; |
| width: 200px; |
| height: 200px; |
| } |
| #anchor { |
| width: 100px; |
| height: 100px; |
| anchor-name: --anchor; |
| } |
| #anchored { |
| position: absolute; |
| width: 100px; |
| height: 100px; |
| position-anchor: --anchor; |
| align-self: anchor-center; |
| left: anchor(--unknown right, 0px); |
| } |
| </style> |
| <div id="cb"> |
| <div id="anchor"></div> |
| <div id="anchored"></div> |
| </div> |
| <script> |
| test(() => { |
| assert_equals(anchored.offsetLeft, 0); |
| assert_equals(anchored.offsetTop, 0); |
| }, "Anchored initially have the same width as the anchor"); |
| |
| test(() => { |
| anchor.style.height = "200px"; |
| assert_equals(anchored.offsetLeft, 0); |
| assert_equals(anchored.offsetTop, 50); |
| }, "Increase the height of the anchor to move the anchor-center offset"); |
| </script> |