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

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

问题描述

给定一个相对简单的 CSS:

div {宽度:150px;}

12333-2333-233-23339392-332332323

<块引用>

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

解决方案

用这个替换连字符:

&shy;

它被称为软"连字符.

div {宽度:150px;}

12333&shy;2333&shy;233&shy;23339392&shy;332332323

Given a relatively simple CSS:

div {
  width: 150px;
}

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

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;

It's called a "soft" hyphen.

div {
  width: 150px;
}

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

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

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