CSS3动画(简单动画的实现,如旋转等)

时间:2020-05-01

CSS animation 属性是 animation-name,animation-duration, animation-timing-function,animation-delay,animation-iteration-count,animation-direction,animation-fill-mode 和 animation-play-state 属性的一个简写属性形式。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        #p {
            background-color: deeppink;
            width: 400px;
            height: 200px;
            margin-top: 100px;
            margin-left: 100px;
            animation: test 5s linear infinite;;
        }

        @keyframes test {
            0% {
                transform: rotate(0deg);
            }
            50% {
                transform: rotate(180deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }
    </style>
</head>
<body>
<div id="p"></div>
</body>
</html>