我有一个很大的问题,我想解决。
问题
代码示例
.box {
width:150px;
border: 2px solid black;
}
<div class="box">
<p>THIS IS A LONG STRING<br>
BUT_THIS_WOULD_BE_THE_PRBLEM_WHEN_A_STRING_HAVE_NO_SPACES!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
</div>
也许有人知道如何显示Text喜欢这个。(仅限JS,JQuery,CSS)
通缉结果
.box {
width: 150px;
border: 2px solid black;
}
<div class="box">
<p>THIS IS A LONG STRING<br>AND_THIS_IS_THE-<br>CONVERTED_STR-<br>ING
</div>
答案 0 :(得分:2)
也许你应该使用word-wrap
允许长词能够破解并换行到下一行:
.box {
width:150px;
border: 2px solid black;
word-wrap: break-word;
}
&#13;
<div class="box">
<p>THIS IS A LONG STRING<br>
BUT_THIS_WOULD_BE_THE_PRBLEM_WHEN_A_STRING_HAVE_NO_SPACES!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p>
</div>
&#13;