Forum Moderators: not2easy

Message Too Old, No Replies

Truncate multi-line text and keep it centered

         

greencode

7:04 pm on Jul 28, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



I've been battling with this for most of the day and beginning to think it's simply not possible.

I have a div 100% wide by a set height i.e. 60px. In that there's some text that could be a few words or could be a lot and so need to truncate it but it will span over 2-3 lines. But I also need to keep whatever text is in that div centered horizontally and vertically.

I've tried to use the dotdotdot script but that does't work when you're centering vertically i.e. using a table-cell.

Any ideas or help would be greatly appreciated.

rainborick

7:56 pm on Jul 28, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I found one solution online. Dunno if it would work for you. Search on "Pure CSS for multiline truncation with ellipsis".

greencode

11:35 am on Jul 29, 2016 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for this but they're not ideal solutions. The main issue is I still would not be able to centre text vertically within the block.

not2easy

2:50 pm on Jul 29, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Can you share the CSS that defines the block? Without seeing what is there it is difficult to guess what might help.