动画的基本使用

2022-12-15 13:51:28发布
39
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background: red;
            animation: test 1s ease 0s infinite alternate both;
        }

        @-webkit-keyframes test {
            0% {
                opacity: 1;
            }

            100% {
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <div></div>
</body>
</html>

css3动画api地址: https://www.runoob.com/cssref/css3-pr-animation.html


动画执行完毕后,用js监听