连字符后没有换行符 [英] No line-break after a hyphen

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

问题描述

我希望在符合所有浏览器的情况下,在连字符 - 之后防止换行。

I'm looking to prevent a line break after a hyphen - on a case-by-case basis that is compatible with all browsers.

例如:

我有这个文字: 3-3 / 8在HTML中是这样: 3-3 / 8& rdquo;

I have this text: 3-3/8" which in HTML is this: 3-3/8”

问题是,一个线,因为连字符,它打破和包装到下一行,而不是像一个完整的词...。

The problem is that near the end of a line, because of the hyphen, it breaks and wraps to the next line instead of treating it like a full word...

3-
3/8"

我尝试插入zero width no  没有运气...

I've tried inserting the "zero width no break character",  with no luck...

3-3/8”

我在Safari中看到这个,并认为它会在所有浏览器中都一样。

I'm seeing this in Safari and thinking it will be the same in all browsers.

以下是我的 doctype 和字符编码...

The following is my doctype and character encoding...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

有什么方法可以防止这些连字符后的换行符?我不需要任何适用于整个页面的解决方案...只是一些我可以根据需要插入,像一个零宽度没有休息字符,除了一个工作。

Is there any way I can prevent these from line-breaking after the hyphen? I do not need any solution that applies to the whole page... just something I can insert as needed, like a "zero width no break character", except one that works.

这是一个演示。只需将框架变窄,直到连字符处换行。

Here is a Demo. Simply make the frame narrower until the line breaks at the hyphen.

http:// jsfiddle .net / RagKH /

推荐答案

尝试使用不间断的连字符 8209; 。我用你的jsfiddle中的那个字符替换了破折号,把框架缩小到可以移动的那么小,这条线不会再分开了。

Try using the non-breaking hyphen &#8209;. I've replaced the dash with that character in your jsfiddle, shrunk the frame down as small as it can go, and the line doesn't split there any more.

这篇关于连字符后没有换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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