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

2015-01-20 09:12:45 +08:00
 roricon
3271 次点击
所在节点    反馈
12 条回复
saximoer
2015-01-20 09:54:16 +08:00
一串字符串貌似浏览器以为是一个整体,不会截断的?
abelyao
2015-01-20 10:44:51 +08:00
@saximoer 那要看 CSS 中 word-break 属性怎么设置了,如果是 break-all 则会拆分单词强制换行。
Keinez
2015-01-20 10:45:43 +08:00
右上角-->设置-->自定义CSS,输入如下:

a {
word-break: break-word;
}

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

a {
word-break: break-all;
}

对于链接得这么搞……
0x1e240
2015-01-20 11:29:20 +08:00
body { word-wrap: break-word !important; }
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
2015-01-20 12:54:41 +08:00
@abelyao 受教啦~
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
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
2015-01-20 15:30:35 +08:00
@MinonHeart
所以正文用 break-word,链接用 break-all。
MinonHeart
2015-01-20 15:36:14 +08:00
@Keinez 嗯。有 word-break: break-word; 这种写法?
你上面说的问号处换行,是?号被当作断点字符了
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 就好了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/163698

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX