像aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa这样的文本超过了div的宽度(比如200px),如何被包装?
我是开放的任何一种解决方案,如CSS, jQuery等。
像aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa这样的文本超过了div的宽度(比如200px),如何被包装?
我是开放的任何一种解决方案,如CSS, jQuery等。
当前回答
试试这个
div {display: inline;}
其他回答
试试这个
div {display: inline;}
<p style="word-wrap: break-word; word-break: break-all;">
Adsdbjf bfsi hisfsifisfsifs shifhsifsifhis aifoweooweoweweof
</p>
你可以像这样使用软连字符:
啊
这将显示为
aaaaaaaaaaaaaaa-
aaaaaaaaaaaaaaa
如果装盒不够大,或者
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
如果是的话。
在HTML正文中尝试:
<table>
<tr>
<td>
<div style="word-wrap: break-word; width: 800px">
Hello world, how are you? More text here to see if it wraps after a long while of writing and it does on Firefox but I have not tested it on Chrome yet. It also works wonders if you have a medium to long paragraph. Just avoid writing in the CSS file that the words have to break-all, that's a small tip.
</div>
</td>
</tr>
</table>
在CSS正文尝试:
background-size: auto;
table-layout: fixed;
来自CSS技巧的例子:
div {
-ms-word-break: break-all;
/* Be VERY careful with this, breaks normal words wh_erever */
word-break: break-all;
/* Non standard for webkit */
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
这里有更多的例子。