replaced-element-031.html (1663B)
1 <!DOCTYPE html> 2 <title>CSS aspect-ratio: img block 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 .border1 { 8 border-left: 10px solid green; 9 } 10 .border2 { 11 border-left: 15px solid green; 12 } 13 </style> 14 15 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 16 17 <!-- 18 1st: A green rect 50x100. 19 border-left is 10x100 and the content box is 40x100. 20 We use 'aspect-ratio: auto && <ratio>', so the aspect-ratio works with 21 content-box dimensions always. The inline size of the content box is 22 (50px - 10px) = 40px, so the block size is 40px * 5/2 = 100px. 23 (note: width here is the inline size of border-box.) 24 25 2st: A green rect 25x100. 26 border-left is 15x100 and the content box is 10x100. 27 (note: width here is the inline size of content-box.) 28 29 3nd: A green rect 25x100. 30 border-left is 15x100 and the content box is 10x100 because we compute 31 the block size by aspect-ratio which works with border-box and so the 32 block size is 25px * 4 = 100. 33 (note: width here is the inline size of border-box.) 34 --> 35 <img class="border1" src="support/20x50-green.png" style="width: 50px; aspect-ratio: auto 1/1; box-sizing: border-box;" 36 ><img class="border2" src="support/20x50-green.png" style="width: 10px; aspect-ratio: 1/10; box-sizing: content-box;" 37 ><img class="border2" src="support/20x50-green.png" style="width: 25px; aspect-ratio: 1/4; box-sizing: border-box;">