<wbr>实现URL地址换行实例页面
回到相关文章 »效果:
代码:
CSS代码:
.box {
width: 150px;
background-color: #cd0000;
color: #fff;
}
HTML代码:
<div id="box" class="box"></div>
JS代码:
String.prototype.urlWbr = function () {
return this.replace(/http(?:s)?:\/\/(.*)\//gi, function (matchs, $1) {
return matchs.replace($1, $1.replace(/(\/|\.)/g, '<wbr>$1'));
});
};
box.innerHTML = '本文地址是https://ww...ak/'.urlWbr();