CSS3中的动画效果

1、transition
示例代码:
 
 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>transition</title>
<style>
div{
background-color: #ffff00;
color: black;
transition:background-color 3s linear,color 2s linear,transform 1s linear;
}
div:hover{
transform: rotate(360deg);
background-color: aqua;
color: red;
}
</style>
</head>
<body>
<div>示例文字</div>
</body>
</html>
2、animation
与transition的区别是,transition只定义了起始和结束的状态,动画是这两个状态之间平滑过渡。animation可以指定多个关键帧的状态,从而可以实现更加复杂的动画效果。
示例代码
 
 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>animation</title>
<style>
div{
background-color: #ffff00;
}
@keyframes mycolor{
0%{
background-color: #ffff00;
}
40%{
background-color: aqua;
}
70%{
background-color: darkblue;
}
100%{
background-color: #ffff00;
}
}
div:hover{
animation: mycolor 5s linear;
}
</style>
</head>
<body>
<div>示例文字</div>
</body>
</html>
3、实现动画的方式

(1)linear——匀速
(2)ease-in——慢快
(3)ease-out——快慢
(4)ease——慢快慢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值