line-clamp-017.html (1063B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Overflow: line-clamp with -webkit-box and -webkit-box-orient</title> 4 <link rel="author" title="Andreu Botella" href="mailto:abotella@igalia.com"> 5 <link rel="help" href="https://drafts.csswg.org/css-overflow-4/#line-clamp"> 6 <link rel="match" href="reference/webkit-line-clamp-005-ref.html"> 7 <meta name="assert" content="If display: -webkit-box and -webkit-box-orient: vertical are present on the same box as line-clamp, it becomes a block container, and other flexbox properties don't apply."> 8 <style> 9 .clamp { 10 display: -webkit-box; 11 -webkit-box-orient: vertical; 12 line-clamp: 4; 13 font: 16px / 32px serif; 14 white-space: pre; 15 padding: 0 4px; 16 background-color: yellow; 17 18 /* If display: -webkit-box behaves the same as without line-clamp, 19 * these properties would cause the anonymous inline box to be centered. */ 20 -webkit-box-align: center; 21 -webkit-box-pack: center; 22 align-items: center; 23 justify-content: center; 24 } 25 </style> 26 <div class="clamp"><div>Line 1 27 Line 2 28 Line 3 29 Line 4 30 Line 5</div></div>