block-height-002.html (2088B)
1 <!DOCTYPE html> 2 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#example-174ae518"> 3 <script src='/resources/testharness.js'></script> 4 <script src='/resources/testharnessreport.js'></script> 5 <script src="/resources/check-layout-th.js"></script> 6 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 7 <meta name="assert" 8 content="the stretch examples in the spec are rendered correctly"> 9 10 <style> 11 main { 12 font: 20px/1 Ahem; 13 } 14 </style> 15 <p>These tests assert the behavior described at 16 https://github.com/w3c/csswg-drafts/issues/11044#issuecomment-2599101601 17 </p> 18 19 <main> 20 <!-- Example 9 21 [T]he outer height of the inner box will exactly match the height of the outer box (200px), but its inner height will be 20px less, to account for its margins. 22 --> 23 <div style="height: 200px; border: solid;"> 24 <div style="height: stretch; margin: 10px;" data-expected-height="180"></div> 25 </div> 26 27 <!-- Example 9, second case 28 In the following case, the height of the inner box will exactly match the height of the outer box (200px). 29 --> 30 <div style="height: 200px; margin: 0;"> 31 <div style="height: stretch; margin: 10px;" data-expected-height="200"></div> 32 </div> 33 34 <!-- Example 10 35 Similarly, width: stretch causes the box to fill its container, being 20px narrower than the width of "some more text" (due to the 10px margin) 36 --> 37 <div style="float: left; margin: 0; outline: solid;"> 38 <div style="width: stretch; margin: 10px; background: skyblue;" 39 data-expected-width="260"> 40 text 41 </div> 42 <span>some more text</span> 43 </div> 44 45 <div style="clear: both;"></div> 46 47 <!-- Example 11 48 On the other hand, in this example the container’s height is indefinite, which would cause a percentage height on the child to behave as auto, so height: stretch behaves as auto as well. 49 --> 50 <div style="height: auto; margin: 0; background: orange;"> 51 lorem ipsum<br> 52 cats 53 <div style="height: stretch; margin: 10px; background: lime;" 54 data-expected-height="20">dogs</div> 55 </div> 56 57 </main> 58 59 <script> 60 document.fonts.ready.then(() => checkLayout("main > div > div")); 61 </script>