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? 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;
}
Sign up to request clarification or add additional context in comments.

5 Comments

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?
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.
Here, before this css statement comes we are making autoprefixer ignore or off. so that this style can render
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!
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.