webkit-line-clamp-with-max-height.html (958B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Overflow: -webkit-line-clamp with max-height</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 the -webkit-line-clamp property is set on an element where max-height is also specified, they will interact the same as for line-clamp: that is, the container will clamp after the line given by -webkit-line-clamp, or the last that fully fits in the height, whichever comes earlier."> 8 <style> 9 .clamp { 10 display: -webkit-box; 11 -webkit-box-orient: vertical; 12 -webkit-line-clamp: 5; 13 font: 16px / 32px serif; 14 white-space: pre; 15 padding: 0 4px; 16 background-color: yellow; 17 overflow: hidden; 18 max-height: 4.5lh; 19 } 20 </style> 21 22 <div class="clamp">Line 1 23 Line 2 24 Line 3 25 Line 4 26 Line 5 27 Line 6 28 Line 7</div>