Posted By

chintanhingrajiya on 01/26/17


Tagged

more


Versions (?)

Add … if string is too long


 / Published in: CSS
 

Add ... using css when string or title not fit on place Add … if string is too long

Now, assuming the element has a fixed width, the browser will automatically break off and add the ... for you.

  1. $out = strlen($in) > 50 ? substr($in,0,50)."..." : $in;
  2.  
  3. or
  4.  
  5. .ellipsis {
  6. overflow: hidden;
  7. white-space: nowrap;
  8. text-overflow: ellipsis;
  9. }

Report this snippet  

You need to login to post a comment.