Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css ellipsis on second line

Tags:

html

css

CSS text-overflow: ellipsis on second line, is this possible? I can't find it on the net.

example:

what I want is like this:

I hope someone could help me. I need  an ellipsis on the second line of... 

but what's happening is this:

I hope someone could help me. I ...  
like image 216
Reigel Avatar asked Mar 11 '11 06:03

Reigel


People also ask

How do I use ellipsis text in CSS?

To clip at the transition between characters you can specify text-overflow as an empty string, if that is supported in your target browsers: text-overflow: ''; . This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text.

How do you break a sentence into two lines in CSS?

We use the word–break property in CSS that is used to specify how a word should be broken or split when reaching the end of a line. The word–wrap property is used to split/break long words and wrap them into the next line.


1 Answers

This should work in webkit browsers:

overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; 

browser support

div {   overflow: hidden;   text-overflow: ellipsis;   display: -webkit-box;   -webkit-line-clamp: 3;   -webkit-box-orient: vertical; }  * { font-family: verdana; }
<div>    The <b><a target='_blank' href='https://developer.mozilla.org/docs/Web/CSS/-webkit-line-clamp'>-webkit-line-clamp</a></b> CSS property allows limiting of the contents of a block container to the specified number of lines. It only works in combination with the display  property set to <b>-webkit-box</b> or <b>-webkit-inline-box</b> and the <b>-webkit-box-orient</b> property set to vertical. In most cases you will also want to set overflow to hidden, otherwise the contents won't be clipped but an ellipsis will still be shown after the specified number of lines. When applied to anchor elements, the truncating can happen in the middle of the text, not necessarily at the end. </div>
like image 193
Skeep Avatar answered Sep 21 '22 01:09

Skeep