是否可以缩短容器(最好是 div),以便在不增加高度的情况下动态插入的文本成为“完美”矩形?
<div style="width:800px;">
<div>I'd like these words to look like below, but I'd like to "automatically" set it with a few lines of CSS rather than with jQuery or some other computationally intensive alternative.</div>
</div>
<br>
<div style="width:800px;">
<div style="width:530px;">I'd like these words to look like below, but I'd like to "automatically" set it with a few lines of CSS rather than with jQuery or some other computationally intensive alternative.</div>
</div>
如果可能的话,我想用一个 CSS 设置来做到这一点,但我找不到。我还想避免 javascript 中的循环来执行此操作,因为我必须对很多 div 执行此操作,并且我不希望性能受到影响。
除非我用错了,否则空白似乎没有帮助。
提前谢谢了!
文本对齐:对齐;
本身没有帮助:http: //jsfiddle.net/Q7gcb/4/
最大宽度 + 文本对齐:对齐;
也不起作用:http: //jsfiddle.net/Q7gcb/5/