在断字之前添加连字符 [英] Add hyphen before word-break

查看:249
本文介绍了在断字之前添加连字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是不可能的,但我想知道是否有一种方法自动插入一个连字符到一个长字符串的结尾,没有空格之前打破一个字?此 jsfiddle 演示了我遇到的问题。谢谢。

Maybe this is not possible, but I was wondering if there is a way to automatically insert a hyphen to the end of a long string with no whitespace before breaking a word? This jsfiddle demonstrates the issue I am having. Thank you.

table {
        width:200px; 
        word-wrap:break-word;
        table-layout: fixed;
      }

<table>
  <td>Pneumonoultramicroscopicsilicovolcanoconiosis</td>
</table>


推荐答案

我认为你最好的选择是javascript解决方案。

I think your best bet would be a javascript solution.


  • css3中有一个连字符属性(至少不是在所有的浏览器)我想,但可能有趣,你可以阅读它 here
    这里

  • There is a hyphens property in css3, does not do exactly what you want (at least not in all browsers yet) I think, but might be interesting, you can read on it here or here.

或者这里讨论一下, b $ b 断字符 wordwrap非常长的字符串

Or here they discuss it a little too and mention a javascript plugin hyphenator: wordwrap a very long string

希望其中一些帮助。

这篇关于在断字之前添加连字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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