top-layer-dialog-container.html (996B)
1 <!doctype html> 2 <title>CSS Container Queries Test: Top layer element as a @container</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#container-queries"> 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 #parent { width: 100px; } 9 #dialog { 10 container-type: inline-size; 11 width: auto; 12 border: none; 13 } 14 #child { color: red; } 15 @container (min-width: 200px) { 16 #child { color: green; } 17 } 18 </style> 19 <div id="parent"> 20 <dialog id="dialog"><span id="child"></span></dialog> 21 </div> 22 <script> 23 setup(() => assert_implements_size_container_queries()); 24 25 test(() => { 26 assert_equals(getComputedStyle(child).color, "rgb(255, 0, 0)"); 27 }, "#dialog initially sized by #containing-block"); 28 29 test(() => { 30 dialog.showModal(); 31 assert_equals(getComputedStyle(child).color, "rgb(0, 128, 0)"); 32 }, "#dialog sized by viewport"); 33 </script>