replaced-element-032.html (1765B)
1 <!DOCTYPE html> 2 <title>CSS aspect-ratio: img inline size with box-sizing</title> 3 <link rel="author" title="Mozilla" href="https://www.mozilla.org/"> 4 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio"> 5 <link rel="match" href="../../reference/ref-filled-green-100px-square.xht" /> 6 <style> 7 img { 8 border-top: 40px solid green; 9 } 10 </style> 11 12 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 13 14 <!-- 15 1st: A green rect 60x100. 16 border-top is 60x40 and the content box is 60x60. 17 We use 'aspect-ratio: auto && <ratio>', so the aspect-ratio works with 18 content-box dimensions always. The block size of the content box is 19 (100px - 40px) = 60px, so the inline size is 60px * 1/1 = 60px. 20 (note: height here is the block size of border-box.) 21 22 2nd: A green rect 20x100. 23 border-top is 20x40 and the content box is 20x60. 24 (note: height here is the block size of content-box.) 25 26 3rd: A green rect 10x100. 27 border-top is 10x40 and the content box is 10x60 because we compute 28 the inline size by aspect-ratio which works with border-box and so the 29 inline size is 100px / 10 = 10px. 30 (note: height here is the block size of border-box.) 31 32 4th: A green rect 10x100. 33 border-top is 10x40 and the content box is 10x60 to add up to 10x100. 34 --> 35 <img src="support/1x1-green.png" style="height: 100px; aspect-ratio: auto 1/10; box-sizing: border-box;" 36 ><img src="support/1x1-green.png" style="height: 60px; aspect-ratio: 1/3; box-sizing: content-box;" 37 ><img src="support/1x1-green.png" style="height: 100px; aspect-ratio: 1/10; box-sizing: border-box;" 38 ><img src="support/1x1-green.png" style="width: 10px; aspect-ratio: 1/6; box-sizing: content-box;">