0
点赞
收藏
分享

微信扫一扫

11、动画效果(animation)

王远洋 2022-04-05 阅读 62

1、动画效果(animation)

animation属性值动画名称、动画时间、速度、延迟、次数
animation-name规定需要绑定到选择器的keyframe名称
animation-duration规定完成动画所花费的时间
animation-timing-function规定动画的速度曲线
animation-delay规定在动画开始之前的延迟
animation-iteration-count规定动画播放次数

2、实例(旋转+放大)

  • 2.1、效果:

视频正在审核中…

  • 2.2、源代码:
<!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>11、动画效果(animation)</title>
	<style>
		/* keyframe定义一个动画 */
		@keyframes anim {

			/* from */
			0% {
				transform: rotate(0deg);
			}

			50% {
				transform: rotate(360deg) scale(2);
				background-color: bisque;
			}

			/* to */
			100% {
				transform: rotate(0deg);
				background-color: blanchedalmond;
			}
		}

		/*
		animation:动画名称、动画时间、速度、延迟、次数
		animation-name: 规定需要绑定到选择器的keyframe名称;
		animation-duration: 规定完成动画所花费的时间;
		animation-timing-function: 规定动画的速度曲线;
		animation-delay: 规定在动画开始之前的延迟;
		animation-iteration-count: 规定动画播放次数;
		*/
		.box {
			width: 100px;
			height: 100px;
			background-color: antiquewhite;
			margin: 200px auto;
			animation: anim 3s infinite;

		}
	</style>
</head>

<body>

</body>
<div class="box"></div>

</html>
举报

相关推荐

0 条评论