<!DOCTYPE html>
<html>
<head>
<style>
@keyframes myfirst
{
from{
width:65px;
height:40px;
background:#92B901;
color:#ffffff;
font-weight:bold;
font:12px '微软雅黑', Verdana, Arial, Helvetica, sans-serif;
opacity:0.4;
}
to{
transform: rotate(360deg);
opacity:1;
background:#1ec7e6;
width:90px;
height:60px;
font-size:16px;
}
}
div{
animation:myfirst 1s;
animation-iteration-count:2;
animation-direction:alternate;
width:65px;
height:40px;
background:#92B901;
color:#ffffff;
position:absolute;
font-weight:bold;
font:12px '微软雅黑', Verdana, Arial, Helvetica, sans-serif;
padding:20px 10px 0px 10px;
margin:5px;
border-radius:5px;
opacity:0.4;
}
span{
position:absolute;
left:23px;
top:50px;
}
</style>
</head>
<body>
<span>动画演示</span>
<div class="animated_div">CSS3过渡</div>
</body>
</html>

本文展示了一个使用CSS3实现的动画案例,通过关键帧动画和过渡效果改变元素的宽度、高度、背景颜色、透明度及旋转角度。初始状态下的元素尺寸较小,背景颜色为绿色,透明度较低。在动画过程中,元素逐渐增大,背景变为蓝色,完全可见,并完成一次旋转。
850

被折叠的 条评论
为什么被折叠?



