roricon
V2EX  ›  反馈

时间轴内,如果 url 过长,不会被正确的折行。

  •  
  •   roricon · Jan 20, 2015 · 4149 views
    This topic created in 4143 days ago, the information mentioned may be changed or developed.
    12 replies    2015-01-20 15:52:07 +08:00
    saximoer
        1
    saximoer  
       Jan 20, 2015
    一串字符串貌似浏览器以为是一个整体,不会截断的?
    abelyao
        2
    abelyao  
       Jan 20, 2015   ❤️ 1
    @saximoer 那要看 CSS 中 word-break 属性怎么设置了,如果是 break-all 则会拆分单词强制换行。
    Keinez
        3
    Keinez  
       Jan 20, 2015
    右上角-->设置-->自定义CSS,输入如下:

    a {
    word-break: break-word;
    }

    保存刷新。
    Keinez
        4
    Keinez  
       Jan 20, 2015
    @Keinez 查了一下属性和效果,修正一下:

    a {
    word-break: break-all;
    }

    对于链接得这么搞……
    0x1e240
        5
    0x1e240  
       Jan 20, 2015
    body { word-wrap: break-word !important; }
    Keinez
        6
    Keinez  
       Jan 20, 2015
    @0x1e240

    使用 break-word 的情况下你可以试试输入这个链接:

    http://login.sina.com.cn/cgi/login/logout.php?r=http://mail.sina.com.cn/?logout#title=%25E9%2582%25AE%25E7%25AE%25B1%25E9%25A6%2596%25E9%25A1%25B5&action=mailinfo

    你会发现链接在问号处换行,这不是应该有的表现。

    break-all 强制打散单词,直接将单词换行。而这使用在链接上我认为没有什么问题。
    break-word 更适合拉丁语系,当遇到符号时自动将单词换到下一行,这适合于使用正文文本的情况。
    saximoer
        7
    saximoer  
       Jan 20, 2015
    @abelyao 受教啦~
    MinonHeart
        8
    MinonHeart  
       Jan 20, 2015
    @Keinez 电脑上看不出来

    假如width到~号结束出
    ----------------------------
    long word mytestmytestmytestmytest~mytest
    ----------------------------

    ----------------------------
    break-word mytestmytestmytestmytest
    ~mytest
    ----------------------------

    ----------------------------
    word-wrap
    mytestmytestmytestmytest~mytest
    ----------------------------

    word-wrap 的 long word 就不会被截断;
    MinonHeart
        9
    MinonHeart  
       Jan 20, 2015
    @MinonHeart 8L 修正 break-word 为 break-all
    @Keinez mytest code
    ————————————————————
    The word-wrap CSS property is used to specify whether or not the browser may break lines withingoogle words in order to prevent overflow (in other words, force wrapping) when an otherwise unbreakable string is too long to fit in its containing box.
    ————————————————————
    用 break-all,最后的那个 withingoogle 的单词被截断了。如果只是中文那倒没什么
    Keinez
        10
    Keinez  
       Jan 20, 2015
    @MinonHeart
    所以正文用 break-word,链接用 break-all。
    MinonHeart
        11
    MinonHeart  
       Jan 20, 2015
    @Keinez 嗯。有 word-break: break-word; 这种写法?
    你上面说的问号处换行,是?号被当作断点字符了
    Keinez
        12
    Keinez  
       Jan 20, 2015
    @MinonHeart

    “有 word-break: break-word; 这种写法?”
    - 实际上等于是 word-wrap: break-word; 这是 webkit 针对 IE 弄的一个 hack,不出现在 W3C 标准里。

    “问号处换行是?号被当作断点字符了”
    - 没错,但是那是必须考虑的情况吧,URL 里出现各种符号的概率并不小。正文用 break-word 就好了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5160 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 60ms · UTC 09:41 · PVG 17:41 · LAX 02:41 · JFK 05:41
    ♥ Do have faith in what you're doing.