欢迎使用CSDN-markdown编辑器

CSS3 animation(1) 平面旋转rotate

transform:rotate():指定对象的2D rotation(2D旋转)
transform:(180deg) 就是转180度的意思,当然这是静态的。如何要让它旋转起来呢,那就需要和animation配合。
比如从0度 5秒内转到360度

div
{
...
animation:myfirst 5s linear infinite;
...
}

其中 myfirst 是指动画的名称与@keyframes对应 5s指动画的周期 linear指动画的速度是匀速 infinite指动画的执行次数为无限次

@keyframes myfirst
{
    from{transform:rotate(0deg);}
    to{transform:rotate(360deg);}

}

从0度到360度
以下附上全部代码

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 5s linear infinite;
-moz-animation:myfirst 5s linear infinite; /* Firefox */
-webkit-animation:myfirst 5s linear infinite; /* Safari and Chrome */
-o-animation:myfirst 5s linear infinite; /* Opera */
}

@keyframes myfirst
{
    from{transform:rotate(0deg);}
    50%{transform:rotate(180deg);}
    to{transform:rotate(360deg);}

}

@-moz-keyframes myfirst /* Firefox */
{
    from{-moz-transform:rotate(0deg);}
    50%{ -moz-transform:rotate(180deg);}
    to{  -moz-transform:rotate(360deg);}

}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
    from{-webkit-transform:rotate(0deg);}
    50%{ -webkit-transform:rotate(180deg);}
    to{-webkit-transform:rotate(360deg);}

}

@-o-keyframes myfirst /* Opera */
{
    from{-o-transform:rotate(0deg);}
    50%{ -o-transform:rotate(180deg);}
    to{-o-transform:rotate(360deg);}

}
</style>
</head>
<body>

<div></div>

<p><b>注释:</b>本例在 Internet Explorer 中无效。</p>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值