Din*_*ivu 6 html javascript css jquery
伙计们,我想把我的打字文本改为两行.
这是我的演示
Plz检查此代码
HTML
<div id="container">
<div class="writer">Hi! This is a test text.
<br><br>
Can any one
Help me in this ?.</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JAVA SCRIPT
var txt = $('.writer').text();
var timeOut;
var txtLen = txt.length;
var char = 0;
$('.writer').text('|');
(function typeIt() {
var humanize = Math.round(Math.random() * (200 - 30)) + 30;
timeOut = setTimeout(function() {
char++;
var type = txt.substring(0, char);
$('.writer').text(type + '|');
typeIt();
if (char == txtLen) {
$('.writer').text($('.writer').text().slice(0, -1)); // remove the '|'
clearTimeout(timeOut);
}
}, humanize);
}());
Run Code Online (Sandbox Code Playgroud)
您可以添加white-space: pre-line;声明以.writer打破行,如下所示:
.writer {
font:bold 23px arial;
white-space: pre-line;
}
Run Code Online (Sandbox Code Playgroud)
pre-line此值指示用户代理折叠空白序列.在保留的换行符处打破行,并根据需要填充行框.
| 归档时间: |
|
| 查看次数: |
240 次 |
| 最近记录: |