I want to cut the letters based on the fixed position. Even if there's some margin of error...

Asked 2 years ago, Updated 2 years ago, 48 views

asfsdagsagfsagfsdgh

gsagsdfadgsdhfdgsd

afgsdghdfhsdgsdgasd

Let's say there are three lines

asfsdagsagfsagfsdgh

gsagsdfadgsdhfdgsd

afgsdghdfh

They want to cut it to this length. I don't know what to do.

If you simply cut it by the number of characters, it contains special symbols, capital letters, and spacesI saw that even if you want to cut it in the third line, it goes to the fourth line or it gets cut in the second line. What should I do if I don't want to go beyond the third line?

jquery javascript

2022-09-21 17:25

1 Answers

Stack overflow is the checkpoint.

https://stackoverflow.com/questions/33058004/applying-an-ellipsis-to-multiline-text

The articles below are also worth seeing.

https://css-tricks.com/line-clampin/

Personally, I think it's more robust to use a library controlled by Js than CSS.

Originally, there is a famous library called dotdotdot, but it seems that you have to pay for commercial use. http://dotdotdot.frebsite.nl/

Clamp.js looks good if it's free. https://github.com/josephschmitt/Clamp.js


2022-09-21 17:25

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.