Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-webkit-line-clamp does not work on Chrome unless I make some unrelated CSS change in developer tools

Tags:

I am trying to add ellipsis after a certain number of lines in Chrome. As suggested in various boards, I used the webkit-line-clamp strategy as below

.line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;  
   text-overflow: ellipsis;
   overflow: hidden;
}

So I do not see the ellipsis at the end of the fourth line to begin with, but if I go into the developer tools and make some random change to the CSS in the element (say change the margin of the element, or check and uncheck one of the properties above), then the ellipsis is seen. This is similar to what was reported in https://bugs.chromium.org/p/chromium/issues/detail?id=265836.

Is there a workaround to this issue? I cannot reproduce this issue in a plain html, it seems to only happen in the application for some inexplicable reason.

like image 545
AshD Avatar asked Feb 02 '17 06:02

AshD


People also ask

Why does my CSS not work in Chrome?

Correct CSS encoding and format (for designers) Whether it is from a CMS like WordPress or your custom-built website, Chrome will not load CSS properly for a reason. If your HTML and CSS are not in the same encoding format, you will see broken styling in web pages on Chrome. So, make sure formats are the same for both.

How do I fix Chrome Developer Tools?

# Open the Issues tabOpen DevTools. Click the Go to Issues button in the yellow warning bar. Alternatively, select Issues from the More tools menu. Once you're on the Issues tab, click the Reload page button if necessary.

How do I save CSS changes of styles panel of Chrome Developer Tools?

To save your changes, press CTRL + S when editing the file.


2 Answers

As per a comment from Andyweb, the solution posted at css - multi line line-clamp (ellipsis) doesn't work is something that works for me.

like image 161
AshD Avatar answered Sep 17 '22 17:09

AshD


I had this problem where line clamp didn't work but adding word-wrap:break-word in my styles made it work.

I dunno if this is going to help you guys looking for a solution ,hopefully it will though.

Ps: this happened to me when the div that has line clamp style was wrapped inside another div that has ngIf directive applied to it .

like image 25
Abdul-Rahman Al-Hussein Avatar answered Sep 19 '22 17:09

Abdul-Rahman Al-Hussein