W
W
wartur2012-08-30 11:48:58
css
wartur, 2012-08-30 11:48:58

How to adaptively compose one situation?

Please take jsfiddle.net/HKrX3/2/ as an example .

The problem is as follows.
Here in the first two divs you see the overflow. In one case, an overflow occurs, in the second, a clipping occurs. In addition, there are methods that allow you to beautifully retouch overflow in translucent ways, as well as do ellipsis through CSS.

And what is desirable.
In the other 3 divs, we see the effect that I would like to get. Its description: in case of overflow, reduce the font, maximum to a certain minimum size, if there are few words, then increase the font to a certain maximum size.

Question:
Are there any CSS methods, or ready-made libs, that allow you to do this kind of thing?

Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Sidorov, 2012-08-30
@wartur

jsfiddle.net/uwKb8/ wrote such a crutch, in principle it works, but there are many but

S
Stas, 2012-08-30
@Exwar

The only option that I see is to create a copy of the text somewhere outside the screen and compare the width of the line and the width of the container in which it needs to be entered in a cycle, reducing the font size in each iteration.
I don’t know ready-made solutions, I think that it will not be very difficult to implement this.

I
Igor, 2012-08-30
@igoravr

The easiest way is to count the number of characters in the text and set the desired class or font size for the block. It's a couple of lines in JS or PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question