css实现文字打字变动输出动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现文字打字变动输出动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=IM+Fell+English&display=swap'); *, *::before, *::after { padding: 0; margin: 0; box-sizing: border-box; } body { font-family: 'IM Fell English', serif; background-image: repeating-linear-gradient(60deg, #000 0px, #222 2px, #000 4px); color: #fff; min-height: 100vh; display: grid; place-items: center; overflow: hidden; } .container { position: relative; } button { position: absolute; left: 50%; top: -0.5em; font: inherit; font-size: 4em; color: #444; background: none; border: none; translate: -50% -50%; opacity: 0.5; -webkit-animation: restart 1s 16s forwards; animation: restart 1s 16s forwards; transition: color 0.3s; &:hover { color: #aaa; } &:active { opacity: 1; color: #fff; &, & ~ .typing::before, & ~ .typing::after { -webkit-animation: none; animation: none; } } } @-webkit-keyframes restart { to { color: #fff; } } @keyframes restart { to { color: #fff; } } .typing { font-size: 48px; text-align: center; &::before { content: ''; -webkit-animation: text 14.5s 1s step-end forwards; animation: text 14.5s 1s step-end forwards; } &::after { content: ''; display: inline-block; width: 0; translate: -0.2em; -webkit-animation: chars 5s 0.5s step-end 3; animation: chars 5s 0.5s step-end 3; } } @-webkit-keyframes text { 0% { content: 'L'; } 2% { content: 'Lo'; } 4% { content: 'Lor'; } 6% { content: 'Lore'; } 8% { content: 'Lorem'; } 10% { content: 'Lorem .........完整代码请登录后点击上方下载按钮下载查看
网友评论0