簡體   English   中英

如何自動換行URL?

[英]How to word-wrap a URL?

自動換行在長字符串上運行良好,沒有任何特殊字符。 我想在URL上使用它。 而不是填充連續的所有列,文本在遇到特殊字符(如=,&等)時進入下一行。是否有其他方法可以解決此問題? 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小提琴在這里

PS:溢出不是很好!

嘗試使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM