| <!DOCTYPE html> |
| <title>CSS Conditional Test: Basic @container anchored(fallback) support</title> |
| <link rel="help" href="https://drafts.csswg.org/css-anchor-position-2/#anchored-container-queries"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/css/css-conditional/container-queries/support/cq-testcommon.js"></script> |
| <style> |
| body { margin: 0; } |
| #anchor { |
| anchor-name: --a; |
| margin-top: 100px; |
| width: 100px; |
| height: 100px; |
| } |
| .anchored { |
| position: absolute; |
| position-anchor: --a; |
| position-area: top; |
| position-try-fallbacks: flip-block; |
| width: 100px; |
| height: 100px; |
| container-type: anchored; |
| } |
| .anchored + .anchored { |
| /* Too tall to fit over the anchor to trigger fallback */ |
| height: 200px; |
| } |
| @container anchored(fallback: none) { |
| div { --fallback: no; } |
| } |
| @container anchored(fallback: flip-block) { |
| div { --fallback: yes; } |
| } |
| </style> |
| <div id="anchor"></div> |
| <div class="anchored"> |
| <div id="t1"></div> |
| </div> |
| <div class="anchored"> |
| <div id="t2"></div> |
| </div> |
| <script> |
| test(() => { |
| assert_equals(document.querySelector(".anchored").offsetTop, 0); |
| assert_equals(getComputedStyle(t1).getPropertyValue("--fallback"), "no"); |
| }, "@container anchored() without applied fallback"); |
| |
| test(() => { |
| assert_equals(document.querySelector(".anchored + .anchored").offsetTop, 200); |
| assert_equals(getComputedStyle(t2).getPropertyValue("--fallback"), "yes"); |
| }, "@container anchored() with fallback applied"); |
| </script> |