这是我的编码。 使用css作为类连字符的结果,结果显示在result1中。 但是,我想要的结果显示在result2中。 另外,在结果1中,当只有几个词时,它会给单词之间的差距造成很大的差距,这真的很难看。 现在有人如何解决这个问题?如何在使用javascript的行尾加密单词
--edit question--
什么我问这里是:我对输入一个textarea和结果div标签。 这是什么方式,以便每当有一个单词达到正确的界限时,该单词就会突破一个新的界限,但是,目标就像结果2所示。 希望现在任何人都能理解。谢谢。
Div标签具有宽度= 170像素,其
.hyphenate{
text-wrap: suppress;
word-break: break-all;
word-wrap: break-word;
white-space: -moz-pre-wrap;
white-space: pre-wrap;
white-space: -o-pre-wrap;
white-space: pre-line;
width:170px;
text-align:justify;
}
-
<script type="text/javascript">
function copyIt() {
var x = document.getElementById("textarea").value;
document.getElementById("result1").innerHTML = x;
}
</script>
-
<table border=2 width="160">
<tr>
<td colspan=2>
<h1>Hyphenator Tester</h1>
</td>
</tr>
<tr>
<td width="160" valign="top">
<textarea id="textarea" rows=5 cols=20 onkeyup="copyIt()">
This is the preview of something What
</textarea>
<br><br>Result:<br>
<div id="result1" class="hyphenate">
This is the preview of something what I've wrote earlier
</div>
<br>Result wanted:<br>
<div id="result2" class="hyphenate">
This is the preview of some- thing what I've wrote earlier
</div>
</td>
</tr>
</table>
我甚至不确定你在这里要求什么,可能想编辑你的请求,使它更清楚你想要达到的目标。 – DoctorLouie 2009-12-17 09:45:16
我说解决方案需要> 2小时才能编码。更好地搜索它。 – 2009-12-17 11:23:13