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

    技术2025-09-15  13

    想让英文自动换行且不断词,就得在换行处给英文单词加上换行连字符"-",这样才能符合印刷规范。下面举个例子:<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)