W
W
WizardW2019-08-09 10:00:13
css
WizardW, 2019-08-09 10:00:13

How to cut off text that doesn't fit?

We need to make sure that each card title is one-line, while not showing a fixed text size, but choosing the amount depending on whether the text will wrap or not. Is there an option to listen to the resize event and check the size of the outer div, if it's larger than necessary, then delete some of the text before the div's size is restored, are there any better/easier options?
5d4d19f0df2f1155693704.png
5d4d19f89b5c6499001615.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Suntsev, 2019-08-09
@GreyCrew

can be done through css, if for the title, then we forbid it to be more than one line like this.

selector{
    display: flex;
    align-items: left;
    max-width: 40px;
    overflow-x: hidden;
    white-space: nowrap;
}

You can put dots at the end of the block For the main text (which is several lines) do the same, just add max-height with overflow-y: hidden; and remove white-space

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question