【发布时间】:2020-08-25 16:14:44
【问题描述】:
我正在尝试为网页上的某些文本添加打字机效果,但是它没有按预期工作。由于这个问题是关于动画的,我在下面给出了小视频(只有 5-6 秒)链接。
- 如何使光标停止超出其需要的位置? See Here
- 这个动画在我打开网站时就开始了,但是这个部分在网页的中间,所以用户看不到那个动画。See here
- 在移动设备上查看时,它不会自行调整。那么我应该怎么做才能让它在小屏幕上自动变小(将整个文本保持在同一行)。 See here
.pcb-text p {
font-size: 60px;
animation: type-writer-effect 3s steps(56), blink-caret 0.85s step-end infinite;
overflow: hidden;
white-space: nowrap;
margin: 0 auto;
border-right: .12em solid orange;
/ width: 28ch;
}
@keyframes type-writer-effect {
0% {
text-align: center;
width: 0ch;
}
100% {
width: 28ch;
}
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from,
to {
border-color: transparent
}
50% {
border-color: orange;
}
}
<div class="pcb-text">
<div class="text-center">
<p>Physics, Chemistry, Biology.</p>
</div>
</div>
【问题讨论】:
-
这里有多个问题需要时间来解决。要获得更清晰的动画,您可以查看different pen,要使其在查看时播放,您需要自定义 JS 或 WowJs 之类的库,这很方便,而对于响应性,您只需使用媒体查询或大小单位,如
em/rem等。抱歉,没有空闲时间完全完成您的任务。 -
@ChrisW.谢谢你的帮助
-
很棒的教程:youtu.be/4Mxv8KcAdLE