animation-container-size.html (1142B)
1 <!doctype html> 2 <title>Container Queries - Animating container size</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#animated-containers"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="support/cq-testcommon.js"></script> 7 <style> 8 @keyframes anim { 9 from { width: 200px; } 10 to { width: 100px; } 11 } 12 #container { 13 container-type: inline-size; 14 animation: anim 1s linear paused; 15 } 16 #target { 17 background-color: green; 18 } 19 20 @container (width: 200px) { 21 #target { 22 background-color: blue; 23 } 24 } 25 </style> 26 <div id=container> 27 <div id=target> 28 Test 29 </div> 30 </div> 31 <script> 32 setup(() => assert_implements_size_container_queries()); 33 34 test(() => { 35 assert_equals(getComputedStyle(target).backgroundColor, 'rgb(0, 0, 255)'); 36 37 assert_equals(container.getAnimations().length, 1); 38 let animation = container.getAnimations()[0]; 39 animation.currentTime = 500; 40 41 assert_equals(getComputedStyle(target).backgroundColor, 'rgb(0, 128, 0)'); 42 }, 'Animation affects container query evaluation'); 43 </script>