Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling dots on text-overflow: ellipsis

Tags:

html

css

Is it possible to style the dots on text-overflow: ellipsis?

An example would be bolding the ellipsis like 'Lorem Ips ...'

like image 562
user2236497 Avatar asked Jun 02 '16 13:06

user2236497


People also ask

How do you style an ellipsis?

The 2019 AP Stylebook, which is the dominant style guide for business writing and web writing, recommends that an ellipsis should be treated as a three-letter word. Format an ellipsis as three periods next to each other with a space before the first period and after the last period.

How do you get the dots at the end of the text when its overflow?

Quite easy thing to do: just add / remove class with text-overflow:ellipsis. JQuery part - basically just removes / adds class cSpanShortText. Highly active question.

How do I change text-overflow ellipsis color?

If the ellipsis is taking the color of the div, then make the div the color you want the ellipsis to be, and use . color to set the initial text black.

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>.


1 Answers

Inspired by this answer, here is a way of styling the ellipsis. The downsides of this solution are

  1. You have to re-assign your default text-styling
  2. You need one more <span> (or what ever) element

.text-overflow
{
  color: blue;
  font-weight: bold;
  font-size: 20px;

  overflow: hidden;
  text-overflow: ellipsis;
  width: 100px;
  white-space: nowrap;
}

.text-overflow > span
{
  font-weight: normal;
  color: black;
  font-size: 14px;
}
<div class="text-overflow"><span>Here is some very nice text indeed. So this is getting long</span></div>
like image 114
Nico O Avatar answered Sep 25 '22 05:09

Nico O