假设我有以下HTML代码片段:
<div id="container">
<div id="textContent">Text Content Te</div>
<div id="anotherText">Another Text Content</div>
</div>
原始HTML输出 http://img26.imageshack.us/img26/1571/beforeeffect.gif
我想知道如何动态调整
元素的
textContent
宽度,以便它能够完美地适应其文本内容(既不会出现换行,也不会出现滚动或截断)。
期望的HTML输出 http://img26.imageshack.us/img26/5851/desiredeffect.gif
我可以接受使用CSS和/或JavaScript的任何解决方案。