dimensions-008-print.html (2094B)
1 <!DOCTYPE html> 2 <link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> 3 <link rel="help" href="https://drafts.csswg.org/css-page-3/#margin-dimension"> 4 <meta name="assert" content="Test auto lengths. Min content sizes are larger than available size. No center/middle boxes."> 5 <meta name="flags" content="ahem"> 6 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css"> 7 <link rel="match" href="dimensions-008-print-ref.html"> 8 <style> 9 :root { 10 print-color-adjust: exact; 11 } 12 @page { 13 margin: 6em; 14 width: 20em; 15 height: 16em; 16 font: 16px/1 Ahem; 17 white-space: pre-wrap; 18 19 /* Total min size is larger than available size. Shrink proportionally to 20 min sizes. */ 21 22 /* Left margin box min: 18em 23 Right margin box min: 6em 24 Flex will be the same as min. Total flex: 18+6=24 25 26 Available space: 20em 27 Unused space: 20em - 24em = -4em 28 29 Left width: 18em + (-4em) * 18/24 = 15em 30 Right width: 6em + (-4em) * 6/24 = 5em */ 31 @top-left { 32 text-align: left; 33 vertical-align: top; 34 content: "xxxxxxxxxxxxxxxxxx x"; 35 margin-bottom: 3em; 36 background: hotpink; 37 } 38 @top-right { 39 text-align: left; 40 vertical-align: top; 41 margin-top: 3em; 42 content: "xxxxxx xxx"; 43 background: yellow; 44 } 45 46 /* Top margin box min: 18em (18 lines) 47 Bottom margin box min: 30em (30 lines) 48 Flex will be the same as min. Total flex: 18+30=48 49 50 Available space: 16em 51 Unused space: 16em - 48em = -32em 52 53 Top height: 18em + (-32em) * 18/48 = 6em 54 Bottom height: 30em + (-32em) * 30/48 = 10em */ 55 @left-top { 56 text-align: left; 57 vertical-align: top; 58 margin-right: 3em; 59 content: "x\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\a"; 60 background: hotpink; 61 } 62 @left-bottom { 63 text-align: left; 64 vertical-align: top; 65 margin-left: 3em; 66 content: "x\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\ax\a"; 67 background: yellow; 68 } 69 </style>