How to word-wrap a URL?

前端 未结 1 728
忘了有多久
忘了有多久 2021-01-19 03:14

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 ro

相关标签:
1条回答
  • 2021-01-19 04:05

    Try using 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>

    0 讨论(0)
提交回复
热议问题