webkit line-clamp (multi-line ellipsis) not working with direction rtl
Asked Answered
K

1

5

Webkit has the property -webkit-line-clamp which supports a multi-line ellipsis.

Take a look at this demo (on a webkit browser of course) and this CSS-tricks article

.wpr {
  overflow: hidden;
}
.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  height: 3.6em;
  /* I needed this to get it to work */
}
<div class="wpr">
  <div class="clamp2">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex
    ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
    augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem.
    Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit
    litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.

  </div>
</div>

So far so good.

The problem is when I add direction:rtl - for right-to-left languages - the -webkit-line-clamp ceases to work - DEMO

Markup

<div class="wpr">
  <div class="clamp3">
  Text
  </div>
</div>

CSS

.wpr
{
  overflow: hidden;
  direction: rtl /* <-- When adding this property ellipsis doesn't work anymore */
}

.clamp3 {
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Maximum of 3 lines of text */
    -webkit-box-orient: vertical;  
    height: 3.6em;
}

.wpr
{
  overflow: hidden;
  direction: rtl;
}

.clamp2 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;  
    height: 3.6em; /* I needed this to get it to work */
}
<div class="wpr">
  <div class="clamp2">
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
  
  </div>
</div

Is this a webkit bug?

Are there any work-arounds?

Kekkonen answered 18/11, 2013 at 8:24 Comment(1)
It looks like old "known issue" that is not gonna be fixed. See more in webkit bug-tracking. Comment from the commit: -webkit-line-clamp and direction:rtl is not supported.Soucy
F
1

AFAIK ellipsis with direction: rtl only works on one line. E.g.:

.ellipsis-rtl {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
}

FWIW, you misspelled direction in your example.

Florella answered 8/3, 2015 at 18:34 Comment(1)
In the demo that I posted I have direction spelled correctly, but it still doesn't work. I'll fix the typo here though. Thanks.Kekkonen

© 2022 - 2024 — McMap. All rights reserved.