連字符後沒有換行符 - No line-break after a hyphen

問題:

I'm looking to prevent a line break after a hyphen - on a case-by-case basis that is compatible with all browsers. 我希望在連字符後防止斷行-在逐個案例的基礎上與所有瀏覽器兼容。

Example: 例:

I have this text: 3-3/8" which in HTML is this: 3-3/8” 我有這樣的文字: 3-3/8"在HTML中是這個: 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"

I've tried inserting the "zero width no break character",  我試過插入“零寬度不中斷字符”,  with no luck... 沒有運氣......

3-3/8”

I'm seeing this in Safari and thinking it will be the same in all browsers. 我在Safari中看到了這一點,並認爲它在所有瀏覽器中都是一樣的。

The following is my doctype and character encoding... 以下是我的doctype和字符編碼......

<!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/ http://jsfiddle.net/RagKH/


解決方案:

參考一: https://en.stackoom.com/question/WGvZ
參考二: https://stackoom.com/question/WGvZ
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章