简体   繁体   English

多种字体大小-Javascript / jQuery键入效果

[英]Multiple font sizes - Javascript/jQuery typing effect

I have created a simple typing effect, as Illustrated here: http://jsfiddle.net/kitsonbroadhurst/fzf70ttg/9/ 我创建了一个简单的打字效果,如下图所示: http : //jsfiddle.net/kitsonbroadhurst/fzf70ttg/9/

My issue is that as the large text is typed it moves the whole line up and down. 我的问题是,在键入大文本时,它将上下移动整个行。

Is it possible to keep the text all on the same level as multiple fonts styles and sizes are added? 添加多种字体样式和大小时,是否可以将文本全部保持在同一水平? (ie as large fonts are added the smaller text does not move vertically) (即,添加大字体时,较小的文本不会垂直移动)

I have tried to use a position: relative wrapper div and then position: absolute to keep everything on the same line, but this did not work. 我尝试过使用position: relative包装器div,然后使用position: absolute将所有内容保持在同一行,但这没有用。

.wrapper {
    position: relative;
}

.text-box {
    position: absolute; 
    bottom: 0;
}

I would rather not use any type of plugin and would prefer a coded solution. 我宁愿不使用任何类型的插件,而宁愿使用编码解决方案。

Set a line height so it won't jump: 设置线条高度,使其不会跳动:

p { line-height: 75px; }

With the box model, the browser will calculate the height dynamically according to text size. 使用box模型时,浏览器将根据文本大小动态计算高度。 Putting a hard size on the element will prevent this. 在元素上放置硬尺寸可以防止这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM