webkit-line-clamp-045.html (1176B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Overflow: -webkit-line-clamp causes display: -webkit-box 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-005-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"> 8 <style> 9 .clamp { 10 display: -webkit-box; 11 -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 overflow: hidden; /* can be removed once implementations update their old -webkit-line-clamp implementations */ 18 19 /* If display: -webkit-box behaves the same as without -webkit-line-clamp, 20 * these properties would cause the anonymous inline box to be centered. */ 21 -webkit-box-align: center; 22 -webkit-box-pack: center; 23 align-items: center; 24 justify-content: center; 25 } 26 </style> 27 28 <div class="clamp">Line 1 29 Line 2 30 Line 3 31 Line 4 32 Line 5</div>