webkit-line-clamp-046.html (1152B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Overflow: -webkit-box-orient: vertical is needed for -webkit-line-clamp to create a block formatting context</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-046-ref.html"> 7 <meta name="assert" content="-webkit-line-clamp causes display: -webkit-box to create a block box, rather than to behave like display: flex as it would otherwise. However, this is only the case with -webkit-box-orient: vertical."> 8 <style> 9 .clamp { 10 display: -webkit-box; 11 /* no -webkit-box-orient: vertical; */ 12 -webkit-line-clamp: 4; 13 font: 16px / 32px serif; 14 white-space: pre; 15 background-color: yellow; 16 padding: 0 4px; 17 18 /* If display: -webkit-box behaves the same as without -webkit-line-clamp, 19 * these properties will 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 27 <div class="clamp">Line 1 28 Line 2 29 Line 3 30 Line 4 31 Line 5</div>