本文介绍了用CSS限制每行的字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一段文字:
<p>Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum</p>
如何确保使用CSS在一行上显示的字符不超过30个?
How can I make sure that no more than 30 characters are shown on one line with CSS?
推荐答案
这是CSS不可能的,你必须使用Javascript。虽然您可以将 p
的宽度设置为多达30个字符,然后下一个字母将自动下降,但是这又不会准确,因此如果字符都在首都。
That's not possible with CSS, you will have to use the Javascript for that. Although you can set the width of the p
to as much as 30 characters and next letters will automatically come down but again this won't be that accurate and will vary if the characters are in capital.
这篇关于用CSS限制每行的字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!