如何包装URL? [英] How to word-wrap a URL?
本文介绍了如何包装URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Word包装适用于没有任何特殊字符的长字符串。我想在一个URL上使用它。而不是填充行中的所有列,文本会遇到特殊字符,如=,&有没有其他方法来解决这个问题?
HTML:
Word wrap works well on long strings without any special characters. I'd like to use it on a URL. Rather than filling all the columns in a row, the text goes to the next row on encountering special characters like =, & etc. Is there some other method to solve this? HTML:
<div style="word-wrap: break-word; width:100px;" id="foo"></div>
JS:
var div = document.getElementById("foo");
div.innerHTML = "https://www.google.co.in/search?q=hello+world&ie=utf-8&oe=utf-8&gws_rd=cr&ei=aNqUVZ7ZK4KVuATI3IGIDg";
JS Fiddle 此处。
JS Fiddle here.
PS:溢出不是很好!
PS: Overflow isn't very nice!
推荐答案
尝试使用 word-break:break-all;
var div = document.getElementById("foo");
div.innerHTML = "https://www.google.co.in/search?q=hello+world&ie=utf-8&oe=utf-8&gws_rd=cr&ei=aNqUVZ7ZK4KVuATI3IGIDg";
#foo{
word-break: break-all;
}
<div style="width:100px;" id="foo">
</div>
这篇关于如何包装URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文