Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Line Clamp is not working with text align justify

Why -webkit-line-clamp is not showing proper ellipsis with text-align:justify. It's working fine with text-align:left/right.

Please suggest any trick.

div {
    text-align: justify;
    width:150px;
    padding: 0 5px;
    line-height: 18px;
    display: -webkit-box;
    display: -moz-box;
    display: -ms-box;
    max-width: 100%;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
<div>Why Line Clamp is not working with text align justify</div>
like image 394
akash Avatar asked Mar 15 '23 04:03

akash


2 Answers

I solved with:

/* autoprefixer: off */
-webkit-box-orient: vertical;
/* autoprefixer: on */
like image 172
Alessio Campanelli Avatar answered Mar 24 '23 10:03

Alessio Campanelli


Check out this Fiddle I don't know why in your CSS it is not working, have changed some and did some Experiments, working for me. :)

CSS:

.line-clamp {
    text-align: justify;
    width : 155px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;  
    overflow: hidden;
    text-overflow: ellipsis;
}

HTML

<div class="line-clamp">Why Line Clamp is not working with text align justify</div>

Hope this will Work for you, or Help you to Solve your Issue.

like image 31
Hardik Bharadava Avatar answered Mar 24 '23 09:03

Hardik Bharadava