Skip to main content

Text Paragraph Truncate - CSS

 

Use the -webkit-line-clamp property to truncate the text to a specific number of lines.

DEMO

This text is trimmed to 3 lines

You can use -webkit-line-clamp property to truncate the text to the specific number of lines. An ellipsis will be shown at the point where the text is clamped.


This text is trimmed to 4 lines

You can use -webkit-line-clamp property to truncate the text to the specific number of lines. An ellipsis will be shown at the point where the text is clamped. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

HTML

<h3>This text is trimmed to 3 lines</h3>
<div class="tile-clamp">
  <p class="line-clamp">
    You can use <code>-webkit-line-clamp</code> property to truncate the text to the specific number of lines.
    An ellipsis will be shown at the point where the text is clamped.
  </p>
</div>
<br>
<h3>This text is trimmed to 4 lines</h3>
<div class="tile-clamp">
  <p class="line-clamp line-clamp--four">
    You can use <code>-webkit-line-clamp</code> property to truncate the text to the specific number of lines.
    An ellipsis will be shown at the point where the text is clamped.
  </p>
</div>

CSS

.tile-clamp {
  background: Aqua;
  padding: 15px;
  margin-bottom: 15px;
  padding: 15px;
  width: 300px;
}

.line-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: 3;
}

.line-clamp--four {
  -webkit-line-clamp: 4; 
}

Comments

Popular posts from this blog

Create Vertical Text - CSS

From the old internet, the direction of text is pretty much fixed on left-to-right. In modern CSS has addressed the issue and supports vertical text with ease. Right to Left Vertical Text Right to Left Vertical Text HTML <div class= "v-rl" > <p> Right to Left </p> <p> Vertical Text </p> </div> CSS .v-rl { writing - mode : vertical - rl; } Left to Right Vertical Text Left to Right Vertical Text HTML <div class= "v-lr" > <p> Left to Right </p> <p> Vertical Text </p> </div> CSS .v-lr { writing - mode : vertical - lr; } All Characters Upright All Characters Upright Ultraman ウルトラマン HTML <div class= "t-upright" > <p> All Characters </p> <p> Upright </p> <p> Ultraman ウルトラマン </p> </div> CSS .t-upright { writing - mode : vertical - rl; text - orie...

Input Range with CSS

  Use ::in-range and ::out-of-range pseudo-classes to style input depending on input value. DEMO 1 to 10 are valid. HTML < label > 1 to 10 are valid .</ label > < input type = "number" value = "1" min = "1" max = "10" > CSS input : in - range { background - color: limegreen; } input :out - of - range { background - color: orange; }

Distortion Glitch Text Effect - CSS

  Use multiple text-shadow properly in CSS on a text by comma separating the values. DEMO Distortion CSS h2 { color : darkorange ; font-family : sans-serif ; font-size : 3.5em ; text-transform : uppercase ; text-shadow : -3px -3px 0 cyan , 3px 3px 0 pink ; }