text-wrap-balance-line-clamp-004.html (1872B)
1 <!DOCTYPE html> 2 <html lang="en" > 3 <meta charset="utf-8"> 4 <title>CSS test: balancing and line-clamp</title> 5 <link rel='author' title='Andreu Botella' href='mailto:abotella@igalia.com'> 6 <link rel='help' href='https://drafts.csswg.org/css-overflow-4/#line-clamp'> 7 <link rel='help' href='https://drafts.csswg.org/css-text-4/#text-wrap-style'> 8 <meta name="assert" content="If the element is affected by line-clamp, the clamping effect is applied first, then the remaining lines are balanced. If the last line is displaced by the line-clamp ellipsis, the content of the previous lines should be balanced into the displaced line if possible, but in this case it isn't."> 9 <link rel="match" href="reference/text-wrap-balance-line-clamp-004-ref.html"> 10 <style> 11 div { 12 border: solid; 13 font-family: monospace; 14 margin: 1ch; 15 width: 9.1ch; /* .1ch to work around browser bugs */ 16 } 17 .test { 18 border-color: blue; 19 20 text-wrap-style: balance; 21 line-clamp: 3; 22 /* This code is unnecessary in any browser that supports the unprefixed version of line-clamp, 23 but neither does it have any detrimental effect, 24 and it broadens the test to browsers that only support the prefixed version */ 25 26 -webkit-line-clamp: 3; 27 display: -webkit-box; 28 -webkit-box-orient: vertical; 29 overflow: hidden; 30 } 31 .ref { 32 border-color: orange; 33 } 34 </style> 35 36 <p>Test passes if the box with a blue frame is identical to the orange one. 37 38 <div class=test>12345678 123456 123456789012 123</div> 39 40 <div class=ref>12345678<br>123456<br>…</div> 41 42 <!-- 43 unbalanced layout without clamping: 44 |---------| 45 |12345678 | 46 |123456 | 47 |123456789012 48 |123 | 49 |---------| 50 51 unbalanced layout after clamping: 52 |---------| 53 |12345678 | 54 |123456 | 55 |… | 56 |---------| 57 58 There is no way to balance this without changing the number of lines. 59 -->