如何在连字符(-)之类的特殊字符后打断单词 [英] How to break word after special character like Hyphens (-)

查看:104
本文介绍了如何在连字符(-)之类的特殊字符后打断单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个相对简单的CSS:

Given a relatively simple CSS:

div {
  width: 150px;
}

<div>
  12333-2333-233-23339392-332332323
</div>

如何使字符串保持在width范围内 150 的行,并在连字符上换行到新行?

How do I make it so that the string stays constrained to the width of 150, and wraps to a new line on the hyphen?

推荐答案

用以下代码替换连字符:

Replace your hyphens with this:

&shy;

它被称为软"连字符.

div {
  width: 150px;
}

<div>
  12333&shy;2333&shy;233&shy;23339392&shy;332332323
</div>

这篇关于如何在连字符(-)之类的特殊字符后打断单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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