Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to chop a text adding three dots "..."?

Tags:

html

css

I need to chop a text adding tree dots at the end "..." the three dots should appear only on the second line of the text. This jsfiddler show the example for one line, but I not able to display two lines of text before adding dots. Any idea how to solve it?

http://jsfiddle.net/hT3YA/263/

#test { 
    background:#eee; 
    border:1px dotted #ccc; 
    margin:1em; 
    padding:5px; 
    width:100px;
    height:200px;
}
.crop { 
    overflow:hidden; 
    white-space:nowrap;
    text-overflow:ellipsis; 
    width:200px; }



<div id="test" class="crop">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
</div>
like image 501
GibboK Avatar asked Sep 12 '13 12:09

GibboK


People also ask

Can I use text-overflow ellipsis?

The text-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped, display an ellipsis (...), or display a custom string.

How can I show dots in a span with hidden overflow?

To add an ellipsis in the HTML <span> element having the CSS overflow property set to “hidden”, you need to add the text-overflow property. Use its “ellipsis” value, which will add dots at the end of the content within the <span>.

How do I show a dot in HTML?

The Unicode and HTML Entities for Bullet Points Then type the 2022 number in, and then add a semi-colon. So, it becomes &#x2022; . Apart from the &#x2022; Unicode character, you can also use &bull; and &#8226; HTML entitles to show bullets or dot symbols on the web page.


1 Answers

Solution here ONLY for webkit, thanks for your comments.

http://jsfiddle.net/hT3YA/268/

#test { 
    background:#eee; 
    border:1px dotted #ccc; 
    margin:1em; 
    /*padding:5px; */
    /*width:100px;*/

}
.crop {
     display: -webkit-box;
     width: 200px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
     overflow: hidden;
     text-overflow: ellipsis;
 }


<div id="test" class="crop">
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
</div>
like image 164
GibboK Avatar answered Sep 22 '22 10:09

GibboK