HTML: Soft hypen (­) without dash?

◇◆丶佛笑我妖孽 提交于 2019-12-30 08:13:08

问题


I have a little layout problem: on a clients website, we show contact information of people in a little box. The width of that box is constrained. As it happens, there are people with very long names (this is in Germany, after all...), and the email address is a concatenation of the given name and family name. The result: with certain names, the email address overflows the constraints given by the about box.

Inserting a ­ before the @results in the correct line break, but looks like this:

john.doe-
@example.com

Is it possible to suppress that dash? I don't want to use <br />, because for 90% of the names, the available width is more than enough.


回答1:


Though I'm not sure how this does cross-browser (probably pretty well), you could always use the thin space character (&thinsp;) or the zero-width space (&#8203;).++

john.doe&thinsp;@example.com

++ I would not suggest using the zero-width space, as apparently some browsers will not render it correctly (source).




回答2:


Use a zero-width space: &#8203;

john.doe&#8203;@example.com

In action here: http://jsfiddle.net/uTXwx/1/




回答3:


You may want to have a look on css property word-wrap.

And this page seems to be doing what you want.




回答4:


If you're willing to drop support for Internet Explorer 11, then you can use the <wbr> element. This is probably superior to using the zero-width-space, because it won't be copied into the clipboard.

See it in action here

MDN documentation



来源:https://stackoverflow.com/questions/5038920/html-soft-hypen-shy-without-dash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!