W
W
Wasya UK2018-03-22 21:59:01
css
Wasya UK, 2018-03-22 21:59:01

How to hide text outside of a block?

How can I make it so that only 3 lines of text fit and the rest is cut off? I tried to set overflow and max-height, but it got cut off a bit. I would like to do it regardless of the text size.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
ElijahTr, 2018-03-22
@dmc1989

https://codepen.io/elijah_tr/pen/ZxypPr

S
Sergey Epifanov, 2018-03-22
@kacheleff

the approach is correct, as far as I know, there are no ways to limit the block by the number of lines, you can only choose the max-height. Just max-height needs to be selected for a reason: you need to set the text to line-height, and calculate max-height as line-height*N, where N is the number of lines

M
Monty Python, 2018-03-25
@Austin1

text-overflow: ellipsis

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question