一行代码教你写打字机效果

boume 发布于 12-13 16:15 浏览:77 类型:原创 - 随笔 分类:JavaScript - javascript学习 作者原创 版权保护
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        @keyframes typing { from { width: 0; } }
        @keyframes blink-caret { 50% { border-color: transparent; } }

        h1 {
            font: bold 200% Consolas, Monaco, monospace;
            border-right: .1em solid;
            width: 16.5em; /* fallback */
            /* width: 30ch; # of chars */
            margin: 2em 1em;
            white-space: nowrap;
            overflow: hidden;
            animation: typing 20s steps(30, end), /* # of steps = # of chars */
            blink-caret .5s step-end infinite alternate;
        }
    </style>
</head>
<body>
<h1>Typing animation by Lea Verou.</h1>
</body>
</html>

 

标签:
z
给个赞 11 人点赞
收藏 0 人收藏
boume 作者

sss

作者最新