V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
roricon
V2EX  ›  反馈

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

  •  
  •   roricon · 2015-01-20 09:12:45 +08:00 · 3239 次点击
    这是一个创建于 3355 天前的主题,其中的信息可能已经有所发展或是发生改变。
    12 条回复    2015-01-20 15:52:07 +08:00
    saximoer
        1
    saximoer  
       2015-01-20 09:54:16 +08:00
    一串字符串貌似浏览器以为是一个整体,不会截断的?
    abelyao
        2
    abelyao  
       2015-01-20 10:44:51 +08:00   ❤️ 1
    @saximoer 那要看 CSS 中 word-break 属性怎么设置了,如果是 break-all 则会拆分单词强制换行。
    Keinez
        3
    Keinez  
       2015-01-20 10:45:43 +08:00
    右上角-->设置-->自定义CSS,输入如下:

    a {
    word-break: break-word;
    }

    保存刷新。
    Keinez
        4
    Keinez  
       2015-01-20 11:01:04 +08:00
    @Keinez 查了一下属性和效果,修正一下:

    a {
    word-break: break-all;
    }

    对于链接得这么搞……
    0x1e240
        5
    0x1e240  
       2015-01-20 11:29:20 +08:00
    body { word-wrap: break-word !important; }
    Keinez
        6
    Keinez  
       2015-01-20 12:34:45 +08:00
    @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  
       2015-01-20 12:54:41 +08:00
    @abelyao 受教啦~
    MinonHeart
        8
    MinonHeart  
       2015-01-20 14:43:43 +08:00
    @Keinez 电脑上看不出来

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

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

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

    word-wrap 的 long word 就不会被截断;
    MinonHeart
        9
    MinonHeart  
       2015-01-20 15:23:38 +08:00
    @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  
       2015-01-20 15:30:35 +08:00
    @MinonHeart
    所以正文用 break-word,链接用 break-all。
    MinonHeart
        11
    MinonHeart  
       2015-01-20 15:36:14 +08:00
    @Keinez 嗯。有 word-break: break-word; 这种写法?
    你上面说的问号处换行,是?号被当作断点字符了
    Keinez
        12
    Keinez  
       2015-01-20 15:52:07 +08:00
    @MinonHeart

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

    “问号处换行是?号被当作断点字符了”
    - 没错,但是那是必须考虑的情况吧,URL 里出现各种符号的概率并不小。正文用 break-word 就好了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5282 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:29 · PVG 17:29 · LAX 02:29 · JFK 05:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.