0

I need to make elipsis max length on multiline in CSS. So I just:

.body {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

But it doesnt work, however if I set this via Chrome devtools on the selected element (element.style {} ), it works.

Doesnt work:

enter image description here

Works:

enter image description here

As you can see, styles are added in both cases (only for some reason -webkit-box-orient: vertical; is not added in first one).

Any help?

2
  • please add relevant code Commented Apr 4, 2019 at 9:06
  • Are your styles scoped? Where do you add this css?
    – Orlandster
    Commented Apr 4, 2019 at 9:06

1 Answer 1

1

Autoprefixer removes outdated prefixes that are no longer needed. Try using this to ignore the removal of style.

.body {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
   /* autoprefixer: ignore next */
  -webkit-box-orient: vertical;
}
5
  • Well that is interesting. Now styles are applied and it works well. Could you please elaborate a bit more if possible? Is this can be considered as a good approach to my goal? Commented Apr 4, 2019 at 10:36
  • AutoPrefixer parse your CSS and add vendor prefixes to CSS rules. And as I mentioned this rule is already removed so it will not parsed through it.
    – Techie_T
    Commented Apr 4, 2019 at 10:44
  • Here, before this css statement comes we are making autoprefixer ignore or off. so that this style can render
    – Techie_T
    Commented Apr 4, 2019 at 10:45
  • 1
    Oh, just found that line-clamp support is not enough - f.ex. Firefox doesnt support it... Will look other solutions. But your answer is great! Thanks! Commented Apr 4, 2019 at 10:46
  • Yeah, It won't work in other browsers as line-clamp is only works with webkit. Let me know the solution if you get for all the browsers for line clamp
    – Techie_T
    Commented Apr 4, 2019 at 10:49

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.