我是新来的CSS动画,并试图获得文本输入效果。我使用各种在线教程的参考资料来实现它。从当前位置开始CSS类型文本动画而不是0宽度
问题: 当我加入这个div我的网站容器内说900px宽与万物对准中心,动画从0像素宽度开始,得到完成和笨拙滑入中心对齐。
我希望动画不要滑到中心位置,而是要从中心位置开始并优雅地结束。
这是我的代码:
body {
width: 900px;
text-align: center;
}
.typetext {
/* color: lime; */
/* font-family: "Courier";*/
font-size: 20px;
/* margin: 10px 0 0 10px;*/
white-space: nowrap;
overflow: hidden;
width: 100%;
animation: type 4s steps(60, end);
}
.typetext:nth-child(2) {
animation: type2 8s steps(60, end);
}
@keyframes type {
from {
width: 0;
}
}
@keyframes type2 {
0% {
width: 0;
}
50% {
width: 0;
}
100% {
width: 100;
}
}
<body>
<div class="row lead typetext" id="anim5" style="clear:both; padding-top:10px; font-size:25px; font-weight:600;">
<div style="width: 100%; margin: 0 auto;">Getting you investment ready and focused on growth</div>
</div>
</body>
请指导
在某种程度上是的。但我希望文字从左侧开始/显示,而不是从右侧或中间开始。任何方式来做到这一点 –
将.typetext div封装到另一个div。让我们打电话给这个div .mycontainer。 .mycontainer {width:600px; text-align:left; margin:0 auto;}。这工作,但你需要现在的文本的长度。 –