我的div具有固定的高度和宽度。我需要文本来减小字体大小,因为文本内容的长度会增大,从而使文本溢出。我在这里看到了其他几个仅涉及div宽度的问题。因此,有了这些解决方案,我的文字就会垂直溢出。
我真的不在乎解决方案是使用CSS还是javascript。感谢您的提前帮助。
这是我正在尝试使用的代码:
<div class="box">
<span>
This is a really long sentence to demonstrate how it doesn't fit inside the box and doesn't do what I want.
</span>
</div>
.box {
margin: 10px;
width: 200px;
height: 50px;
border: 1px solid black;
}
这里是jsfiddle:https://jsfiddle.net/wnkzy0u8/1/
提供的问题有点不清楚,根本没有任何代码,但是我认为这可能是您要寻找的:jsfiddle.net