[英]How to word-wrap a URL?
Word wrap works well on long strings without any special characters. 自动换行在长字符串上运行良好,没有任何特殊字符。 I'd like to use it on a URL. 我想在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: HTML:
<div style="word-wrap: break-word; width:100px;" id="foo"></div>
JS: 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";
PS: Overflow isn't very nice! PS:溢出不是很好!
Try using word-break: break-all;
尝试使用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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.