如何打破长URL? [英] How to break long URL's?

查看:64
本文介绍了如何打破长URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我目前遇到的问题是长网址或带有

的文本行没有空格会破坏设计一个网页,http://

blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-

rss.html就是一个例子。


有谁知道是否可以使用CSS将这个文本分成多行

行?


在此先感谢,

Kev

Hi,

I''m currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.

Does anyone know if it''s possible to break this text into multiple
lines using CSS?

Thanks in advance,
Kev

推荐答案

07年2月15日:06,kevgibbo < kevgi ... @ gmail.comwrote:
On 15 Feb, 07:06, "kevgibbo" <kevgi...@gmail.comwrote:

我目前遇到的问题是长网址或一行文字带

没有空格会破坏网页的设计,
I''m currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage,



为什么网页的设计可以看到URL?在大多数情况下,

URL应该在href中,但是没有理由将它用作可见的

链接文本。

如果它是故意可见的(并且有充分的理由),那么

只需将它放在自己的行上并给它一些与众不同的

小字体。对于你所描述的中等大小的网址,那么只需要将它们放在一行上就可以了。

没问题,只要它们从

开始就可以了。


巨大的URL是一个坏主意,通常是不必要的,理想情况下应该在源头避免
而不需要它们这么久。

Why is a URL visible to the design of a web page? In most cases, the
URL should be in a href but there''s no reason to use it as the visible
link text.

If it is deliberately visible (and there are good reasons to), then
just place it on its own line and give it some distinctive and
smallish font. For URLs of the moderate size you describe, then it''s
no problem to fit them on a single line, so long as they start from
the beginning of it.

Huge URLs are a bad idea, usually unnecessary and should ideally be
avoided at source by just not needing them to be so long.


有没有人知道是否可以使用CSS将此文本分成多行

行?
Does anyone know if it''s possible to break this text into multiple
lines using CSS?



我会嵌入< brand我会手工完成。做这个有用的背景

这个很少,而且实际上只在教程中。和关于

网页本身的元页面。对于其他任何事情,然后嵌入链接而不是

明显说明它。


(复制航空公司预订网站的URL,以便您可以通过电子邮件发送给

你的伴侣预订假期!Aargh!)

I''d embed <brand I''d do it by hand. The useful contexts for doing
this are few and really only within "tutorials" and meta-pages about
the web itself. For anything else, then embed the link rather than
stating it visibly.

(Copying URLs for airline booking sites so that you can email them to
your partner to book holidays! Aargh!)


Scripsit kevgibbo:
Scripsit kevgibbo:

I 我目前遇到的问题是,长网址或带有

的文本行没有空格会破坏网页的设计,http://

blog.seoptimise .com / 2007/01 / how-to-add-delicious-and-digg-blog-

rss.html就是一个例子。
I''m currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.



最重要的是,不要将URL放入_content_中,只要将其放入

属性值(例如href =")。 ..)长网址不会受到伤害。


粗略地说,只有在页面

_discusses URL_时,网址才会出现在内容中。例如,如果您希望编写一个页面如何通过Web创作或电子邮件中的URL或打印

媒体来引用某些文档,您可能需要一些示例网址,可能相当长。然后

首要问题是_prevent_浏览器破坏它们!


重点是长URL通常不会对内容造成伤害,除非它

出现在文本段落的中间,它不应该出现,或者

你有一个严格的页面布局,你不应该有。


但是_is_有害的是浏览器在连字符 - 之后断开URL,因为它可能会很好地完成。读者如何知道或猜测连字符是否是

URL的一部分,还是仅仅通过断字中的连字符引入? (不可否认,

有经验的用户知道浏览器不会连字符。但并非所有用户都有经验。此外,非常有经验的用户知道浏览器可能会

连字符 - 当使用软连字符给出连字符提示时。)

Most importantly, don''t put URLs into the _content_ proper, only into
attribute values (such as href="...") where long URLs won''t hurt.

Roughly speaking, URLs should appear in the content proper only when a page
_discusses URLs_. For example, if you wish to write a page how to refer to
some documents by their URLs in web authoring or in email messages or print
media, you may need some sample URLs, which might be rather long. Then the
prime problem is to _prevent_ browsers from breaking them!

The point is that a long URL usually doesn''t hurt in the content unless it
appears in the middle of a text paragraph, where it should not appear, or
you have a rigid page layout, which you should not have.

But it _is_ harmful is a browser breaks a URL after a hyphen "-", as it may
well do. How will the reader know or guess whether the hyphen is part of the
URL or just introduced by hyphenation in word breaking? (Admittedly,
experienced users know that browsers don''t hyphenate. But not all users are
experienced. Besides, very experienced users know that browsers may
hyphenate - when a hyphenation hint has been given using the soft hyphen.)


有谁知道是否可以将此文本分成多个
使用CSS的
行?
Does anyone know if it''s possible to break this text into multiple
lines using CSS?



如果您确实需要在文档文本中包含长URL,请将它们包装在

里面< nobr> ...< ; / nobrmarkup。您可以在允许

换行符的点之后添加< wbrtags,但是您应该使用一些分隔符或其他

向用户说明构成URL的内容。这是实用的

方式,你只需要容忍那些(正确)尖叫的人

非标准加价!。 CSS原则上可用于防止休息,

因为

< nobr> foo< / nobr>

实际上对应于

< span style =" white-space:nowrap"> foo< / span>

但是我没有看到太多的意思。我不是真的想在实践中没有其他任何东西使用更多

复杂的代码而不是在CSS关闭时我的URL被破坏的风险

。所以这是HTML的工作,而不是CSS。


在CSS 3草案中,有可用于
$ b $的自动换行属性b建议在字符串中允许_any_换行,使用自动换行:

break-word。 IE支持这一点。但它确实是值得避免的。它会违反常识,可读性和几个标准以及建议打破URL _arbitrarily_。


更多信息: http://www.cs.tut.fi/~ jkorpela / html / nobr.html


-

Jukka K. Korpela(Yucca)
http://www.cs.tut.fi/~jkorpela/

If you do need to include long URLs into the text of a document, wrap them
inside <nobr>...</nobrmarkup. You may add <wbrtags after points where a
line break is allowed, but then you should use some delimiters or otherwise
make it clear to the user what constitutes the URL. That''s the practical
way, and you just have to tolerate people who (correctly) scream
"nonstandard markup!". CSS could in principle be used for preventing breaks,
since
<nobr>foo</nobr>
effectively corresponds to
<span style="white-space: nowrap">foo</span>
but I don''t see much point there. I don''t really want to use more
complicated code when nothing else is gained in practice than the risk that
my URLs are broken when CSS is off. So this is a job for HTML, not CSS.

In the CSS 3 drafts, there''s the word-wrap property that could be used to
suggest that _any_ line break is allowed in a string, using word-wrap:
break-word. IE supports this. But it''s really something to be avoided. It
would violate common sense, readability, and several standards and
recommendations to break a URL _arbitrarily_.

More info: http://www.cs.tut.fi/~jkorpela/html/nobr.html

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


2月15日凌晨2:06,kevgibbo < kevgi ... @ gmail.comwrote:
On Feb 15, 2:06 am, "kevgibbo" <kevgi...@gmail.comwrote:

我目前遇到的问题是长网址或一行文字带

没有空格会破坏网页的设计,http://

blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-

rss.html就是一个例子。
I''m currently having a problem where a long URL or a line of text with
no spaces will break the design of a webpage, http://
blog.seoptimise.com/2007/01/how-to-add-delicious-and-digg-blog-
rss.html is an example of this.



我不是说你应该*这样做,因为其他人回复了

指出了不这样做的理由。但是如果你想要一个可以覆盖的URL(或其他冗长的单词或内容

没有空格),我会提出一些建议。而不是插入连字符,零 -

宽度非连接器怎么样? (& zwnj;)或者,你可以插入空格,并且类

锚点或span元素collapsespaces然后使用CSS后面的



..collapsespaces {

字间距:-.33em;

}


语义上,空格仍然存在,这就是为什么zwnj可能是一个更好的主意。此外,您可能需要调整指定的

值,具体取决于您使用的字体,但大多数字体''空格

字符的前进宽度非常接近到1/3 EM。


我同意其他回复此帖子的人,在大多数

的情况下,长网址不应出现在内容。但是我可以想象一下它可能有用的几种情况,甚至可能在一个狭窄的但仍然可变宽度的文本列中需要保持狭窄。或者

也许它不是一个URL,而是一个非常长的(可能是发明的)单词,或者是一些空间稀疏的专用表示法的字符串。我的建议是针对

这些情况。


-

孩子的孩子

I''m not saying you *should* do this, as the other folks to reply have
pointed out reasons not to. But I have a couple of suggestions if you
want a wrappable URL (or other rediculously long "word" or content
with no spaces). Instead of inserting hyphens, how about the zero-
width non-joiner? (&zwnj;) Or, you could insert spaces, and class
the anchor or a span element "collapsespaces" and then use the
following CSS:

..collapsespaces {
word-spacing: -.33em;
}

Semantically, the spaces are still there, which is why zwnj is
probably a better idea. Also, you might have to tweak the specified
value depending on the font you''re using, but most fonts'' space
character has an advance width of very close to 1/3 EM.

I agree with the others who have replied to this thread that, in most
cases, a long URL should not appear in content. But I can imagine a
few situations when it might be of use, possibly even in a narrow but
still variable-width column of text that needs to stay narrow. Or
perhaps it''s not a URL but a very long (possibly invented) word, or a
string of some specialized notation where spaces are sparse. It''s for
these situations that my advice is intended.

--
Vid the Kid


这篇关于如何打破长URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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