怎样让英文自动换行且不断词

想让英文自动换行且不断词,就得在换行处给英文单词加上换行连字符"-",这样才能符合印刷规范。
下面举个例子:
<style>body{background-color:black;color:#CCCCFF;text-align:center}</style>
<script>
function wrap(str,len){
    return str.replace(new RegExp("(.{"+len+"})","igm"),"$1<br/>").replace(/(/w<br//>)(/w)/igm,'$1<font color=#00ff00>-<//font>$2');
}
document.write(wrap(new Array(30).join("Everything has an beginning has an end..."),50));
</script>

或采用英文字段两端对齐的方法,这样两边切齐,比较规矩:

英文对齐:<br>
<div style="font-size:12px;width:300;text-align:justify;text-justify:inter-ideograph">¨Crepower¨ Brand Belts, Chains and other Transmission Parts are manufactured under ISO9001 certified quality-control system. With improved quality material and well-organized production procedures, ¨Crepower¨ power transmission products have noticeably fatigue strength and long-service life.We can supply all types and sizes according to the related standards and customers’ requirements and</div>
<br>

.content {
position: absolute; left: 355px; top: 50px; width: 219px; height:250px;
line-height:150%;text-align:justify;text-justify:inter-ideograph;
/* 注意:设置两端对齐不能强制换行 否则不起作用 即不能加入word-break : break-all;*/

另外强制不换行的代码是white-space:nowrap;

.contenttitle {
position: absolute; left: 355px; top: 20px; width: 219px; height:30px;
line-height:150%;font-size:13px; font-weight:bold; color:#FF3201;
vertical-align:middle;white-space:nowrap; overflow:hidden;

/*强制不换行 zdz的作品,流风的作品*/
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值