为什么不用逗号在一个长字符串上断字工作? [英] Why doesn't break word work on a long string with commas?

查看:114
本文介绍了为什么不用逗号在一个长字符串上断字工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长逗号分隔的字符串,我试图使用CSS样式word-wrap:break word,但它似乎不工作在没有空格的字符串。这是预期吗?



我的表格如下所示:

  ; table class =table table-stripedstyle =margin-top:20px; background-color:#f2f2f2;> 
< tbody>
< tr>
< td width =150pxvalign =topstyle =white-space:nowrap;>< b>常用活动:< / b>< / td&
< td width =50pxstyle =word-wrap:break-word;>一些,真,长,长,字符串,逗号,分隔符,列表< / td>
< / tr>
< / tbody>
< / table>

有没有什么工作?

解决方案

word-wrap:break-word; 仍然是实验性的,因此不同的浏览器可能支持或不支持。

如果可以,在逗号后插入零宽度空格。它是Unicode中的U + 2008,或者是HTML中的&#8203; 。浏览器会根据需要在零宽度空间中断开字符串。



另请参阅维基百科


I have a long comma delimited string and I'm trying to use the css style word-wrap:break word but it doesn't seem to work on a string without spaces. Is this expected?

My table looks like this:

<table class="table table-striped" style="margin-top:20px;background-color:#f2f2f2;">
  <tbody>
    <tr>
      <td width="150px" valign="top" style="white-space:nowrap;"><b>Favorite Activities:</b></td>
      <td width="50px" style="word-wrap:break-word;">some,really,really,long,long,string,with,out,any,spaces,just,a,comma,delimited,list</td>
    </tr>
  </tbody>
</table>

Are there any work arounds for this?

解决方案

word-wrap:break-word; is still experimental, so different browsers might support it or not.

If you have can, insert a zero-width space after the commas. It's U+2008 in Unicode, or &#8203; in HTML. The browser will break the string up at the zero-width space as it needs to. You can probably do that in whatever code is producing the HTML, or write some javascript to automatically insert the character.

See also Wikipedia.

这篇关于为什么不用逗号在一个长字符串上断字工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆