使用jQuery创建缓慢填充的文本 [英] Use jQuery to create slowly filling text

查看:101
本文介绍了使用jQuery创建缓慢填充的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
逐个字母显示文本

Possible Duplicate:
Show text letter by letter

有点难以解释,但是我想要实现的是将文本添加到div但我不希望它简单地出现或fadeIn等.我希望能够一次将文本显示为一个字符,例如例如,如果您正在DS上玩基于文本的游戏.

Bit hard to explain but what I'm trying to achieve is add text to a div BUT I don't want it to simply appear or fadeIn etc. I want to be able to display the text a character at a time like if you were playing a text based game on the DS for example.

推荐答案

此处是演示 http://www.thepixelart.com/demo/jticker/

这是可下载文件 http://www.thepixelart.com/demo/jticker/files/jticker.zip

您可以修改计时器,以便在特定时间仅出现一个字符

You can modify the timer so that only one character would appear at particular time

(或)

html

<div id="text"><span>The intergalactic space agency</span></div>

css

div#text {宽度:0像素;高度:2em;空白:nowrap;溢出: 隐; }

div#text { width: 0px; height: 2em; white-space: nowrap; overflow: hidden; }

jQuery

var spanWidth = $('#test span').width(); $('#text').animate({width: spanWidth},1000);

var spanWidth = $('#test span').width(); $('#text').animate( { width: spanWidth }, 1000 );

这是演示

http://jsfiddle.net/mrtsherman/6qQrN/1/

这篇关于使用jQuery创建缓慢填充的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆