css3基础知识点--animation动画

本文介绍了CSS3中用于创建动画的关键知识点,包括@keyframes定义关键帧、animation-name指定动画名、animation-duration设置动画时长、animation-timing-function控制动画速度曲线,以及animation-delay、animation-iteration-count、animation-direction等其他属性。通过实例展示了如何制作人物走路和风车旋转的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

css3基础知识点–animation动画

参数:

1、@keyframes 定义关键帧动画
2、animation-name 动画名称
3、animation-duration 动画时间
4、animation-timing-function 动画曲线

linear 匀速
ease 开始和结束慢速
ease-in 开始是慢速
ease-out 结束时慢速
ease-in-out 开始和结束时慢速
steps 动画步数

5、animation-delay 动画延迟
6、animation-iteration-count 动画播放次数 n|infinite
7、animation-direction

normal 默认动画结束不返回
Alternate 动画结束后返回

8、animation-play-state 动画状态

paused 停止
running 运动

9、animation-fill-mode 动画前后的状态

none 不改变默认行为
forwards 当动画完成后,保持最后一个属性值(在最后一个关键帧中定义)
backwards 在 animation-delay 所指定的一段时间内,在动画显示之前,应用开始属性值(在第一个关键帧中定义)
both 向前和向后填充模式都被应用

10、animation:name duration timing-function delay iteration-count direction;同时设置多个属性

人物走路



    <!DOCTYPE html>
    <html lang="en">
    <head>
    	<meta charset="UTF-8">
    	<title>animation 人物走路动画</title>
    	<style type="text/css">
    		
    		.box{
    			width:120px;
    			height:182px;
    			border:1px solid #000;
    			margin:50px auto 0;
    			overflow:hidden;
    			position:relative;
    		}
     
     
    		.box img{
    			position:absolute;
    			left:0;
    			top:0;
    			animation:walking 1s steps(8) infinite;
    		}
     
    		
    		@keyframes walking{
    			
    			from{
    				left:0px;
    			}
     
     
    			to{
    							left:-960px;
			}
 
		}
	</style>
</head>
<body>
	<div class="box"><img src="images/walking.png"></div>
</body>
</html>

风车旋转

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>animation 动画</title>
	<style type="text/css">
		
		.box{
			width:400px;
			height:400px;
			margin:50px auto 0;
			background:url(images/fengche.png) no-repeat;
			animation:moving 1s linear 0s infinite;
		}
 
		@keyframes moving{
			
			from{
				  transform:rotate(0deg);
			}
 
			to{
				transform:rotate(360deg);
 
			}	
		}
 
	</style>
</head>
<body>
	<div class="box"></div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值