scroll-state-scrollable-pseudo.html (1741B)
1 <!DOCTYPE html> 2 <title>@container: scroll-state(scrollable) for pseudo element</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#scrollable"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/css/css-conditional/container-queries/support/cq-testcommon.js"></script> 7 <script src="/css/css-transitions/support/helper.js"></script> 8 <style> 9 #scroller { 10 container-type: scroll-state; 11 overflow: auto; 12 width: 100px; 13 height: 100px; 14 } 15 #wrapper { 16 width: 10px; 17 height: 10px; 18 } 19 #wrapper.large { 20 width: 75px; 21 height: 75px; 22 } 23 #target { 24 width: 200%; 25 height: 200%; 26 --before: no; 27 --after: no; 28 @container scroll-state(scrollable) { 29 &::before { 30 --before: yes; 31 content: " "; 32 } 33 &::after { 34 --after: yes; 35 } 36 } 37 } 38 </style> 39 <div id="scroller"> 40 <div id="wrapper"> 41 <div id="target"></div> 42 </div> 43 </div> 44 <script> 45 setup(() => assert_implements_scroll_state_container_queries()); 46 47 promise_test(async t => { 48 await waitForAnimationFrames(2); 49 assert_equals(getComputedStyle(target, "::before").getPropertyValue("--before"), "no"); 50 assert_equals(getComputedStyle(target, "::after").getPropertyValue("--after"), "no"); 51 }, "::before/::after initially not matching"); 52 53 promise_test(async t => { 54 wrapper.className = "large"; 55 await waitForAnimationFrames(2); 56 assert_equals(getComputedStyle(target, "::before").getPropertyValue("--before"), "yes"); 57 assert_equals(getComputedStyle(target, "::after").getPropertyValue("--after"), "yes"); 58 }, "::before/::after matching after content starts scrollable #scroller"); 59 60 </script>