Answer the question
In order to leave comments, you need to log in
How to shrink and adapt text when it doesn't fit in a block?
There is a block. It is filled with text on certain events. But with a large amount of text, it goes beyond the border and obscures the block that is nearby.
How to make text responsive? So that its size decreases when the div overflows?
Answer the question
In order to leave comments, you need to log in
I think you can use vh. For example:
.some-text {
font-size: 100vh;
line-height: 100vh;
}
Example:
codepen.io/iiil/pen/yDbtL
When adding text, call the scale function. The step and minfs variables are the font size change step and the minimum font size. When the minimum is reached, a vertical scroll appears.
Surrenders to me that the task is incorrect from the very beginning. What was wrong with scrolling?
function onTextChange() {
var textLength = $('.textHolder').text().length;
var fontSize = Math.min(12, (1000 / textLength) * 12);
//where 12 - typical font-size, 1000 - typical length
$('.textHolder').css('font-size', fontSize+'px');
{
Is this option not suitable?
htmlbook.ru/css/text-overflow
Responsive layout, how to change the font size when changing the block size?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question