transition-scrollbars.html (1741B)
1 <!doctype html> 2 <title>Container Queries - Scrollbars do not cause transitions</title> 3 <link rel="help" href="https://drafts.csswg.org/css-transitions/#starting"> 4 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#animated-containers"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="support/cq-testcommon.js"></script> 8 <style> 9 #scrollable { 10 overflow: auto; 11 width: 100px; 12 height: 100px; 13 } 14 #container { 15 container-type: inline-size; 16 } 17 #target { 18 background-color: black; 19 } 20 21 /* Matches with or without a scrollbar: */ 22 @container (max-width: 100px) { 23 #target { 24 background-color: blue; 25 } 26 } 27 28 /* Matches only when there's a scrollbar: */ 29 @container (max-width: 99px) { 30 #target { 31 background-color: green; 32 font-size: 10px; 33 transition: 2s steps(2, start) background-color; 34 } 35 } 36 </style> 37 <div id=scrollable> 38 <div id=container> 39 <div id=target> 40 Foo bar foo bar foo 41 Foo bar foo bar foo 42 Foo bar foo bar foo 43 Foo bar foo bar foo 44 Foo bar foo bar foo 45 </div> 46 </div> 47 </div> 48 <script> 49 setup(() => assert_implements_size_container_queries()); 50 51 test(() => { 52 // Whether or not a scrollbar appeared is out of scope for this test. 53 // The only thing we care about is that no transition was triggered. 54 // Therefore we allow both 'green' and 'blue', but not any other values. 55 let has_scrollbar = target.offsetWidth < 100; 56 let expected = has_scrollbar ? 'rgb(0, 128, 0)' : 'rgb(0, 0, 255)'; 57 assert_equals(getComputedStyle(target).backgroundColor, expected); 58 }, 'Scrollbars do not cause a transition of background-color'); 59 </script>