* {
margin: 0;
padding: 0px;
box-sizing: border-box;
font-family: consolas;
}
body {
/* 使用弹性布局,实现居中 */
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #121213;
}
.loader {
position: relative;
/* 文字的倒影效果 */
-webkit-box-reflect: below 1px linear-gradient(transparent, #0002)
}
.loader h2 {
position: relative;
color: aliceblue;
letter-spacing: 5px;
/* 文字动画 ,动画的步数就是字符的个数*/
animation: typing 8s steps(10) infinite;
/* 超出的文字隐藏 */
overflow: hidden;
}
/* 光标 */
.loader::before {
content: '';
position: absolute;
top: 0;
right: 0;
width: 2px;
height: 100%;
background: aliceblue;
/* 动画 ,steps将动画分步,动画从0到100%经过3步*/
animation: blinkCursor 0.8s steps(3) infinite;
}
/* 实现光标的闪烁效果 */
@keyframes blinkCursor {
0%,
75% {
opacity: 1;
}
76%,
100% {
opacity: 0;
}
}
@keyframes typing {
0%,
90%,
100% {
width: 0;
}
30%,
60% {
/* 宽度是文字的宽度,通过控制台看出来的 */
width: 181.95px;
}
}
Loading...