Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
            - /css/css-anchor-position/anchor-position-flip-sibling-index.html - WPT Dashboard Interop Dashboard
 
<!DOCTYPE html>
<title>CSS Anchor Positioning Test: flip anchor function with sibling-index()</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#typedef-position-try-fallbacks-try-tactic">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  body { margin: 0; }
  #anchor {
    anchor-name: --a;
    width: 100px;
    height: 100px;
  }
  #abs {
    position-anchor: --a;
    position-try-fallbacks: flip-block;
    position: absolute;
    bottom: anchor(calc(20% * sibling-index()));
    width: 100px;
    height: 100px;
    background: teal;
  }
</style>
<div>
  <div id="anchor"></div>
  <div id="abs"></div>
</div>
<script>
  test(() => {
    assert_equals(getComputedStyle(abs).top, "60px", "100% - (20% multiplied by 2 (sibling-index())) of 100px")
  }, "Percentage based top anchor() position with sibling-index() flipped to bottom");
</script>