css - multi line line-clamp (ellipsis) doesn't work

hagfish1210 picture hagfish1210 · Aug 17, 2016 · Viewed 11.4k times · Source

problem image

I applied this class to h3 tag.

.ellipsis-2 {
  $lines: 2;
  $line-multiple: 1.3;
  $font-size: 1em;
  display: block;
  display: -webkit-box;
  max-height: $font-size * $line-multiple * $lines;
  line-height: $font-size * $line-multiple;
  text-overflow: ellipsis;
  overflow: hidden;
  word-wrap: break-word;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
}

As you saw in image, there is full lines of text and ellipsis didn't show.

But when I resize screen, ellipsis works fine.

Problem occured only the first time page rendering.

Any adivce?

Answer

Eloy Ruiz picture Eloy Ruiz · Nov 12, 2018

This is my solution to this:

HTML

<mat-expansion-panel>
  <mat-expansion-panel-header>
    {{ stuff here }}
  </mat-expansion-panel-header>
  <div class="mat-expansion-panel-content">
    <div class="mat-expansion-panel-body">
      {{ stuff here }}
    </div>
  </div>
</mat-expansion-panel>

CSS

.mat-expansion-panel-body {
  visibility: visible;
}

Set visibility property of the panel content's child to visible.

So, you can avoid the wrong rendering on the first load. I was hitting my head against the wall for two days in order to solve this. I hope it can save someone some time.