CSS3伪类实现动画旋转效果

一个简单的动画效果demo,keyframes为关键帧,图片贴在代码下方。利用了伪类实现css3动画效果,初学者可以看一下,恩。
<!
doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Keywords" content="关键词"> <meta name="Description" content="描述"> <title>css3 animation</title> <style> *{margin:0px;padding:0px;}/*去除默认外边距、内边距*/ body{width:272px;margin:0 auto;} .auto{margin-top:40px;} .auto-rotate{ color:#333; font-weight:bold; font-family:sans-serif; } span{font-size:40px;color:#000;font-weight:bold; font-family:sans-serif;cursor:pointer;} .anticlockwise{float:left;} .clockwise{float:right} .rotate{width:273px;height:273px;margin:auto; background:url("1.jpg") no-repeat;} input:checked ~ .rotate{/*选中input框自动旋转*/ animation:clockwise 1s steps(30) infinite; } /*自定义动画:名称 动一次时间 多少步执行完 无限重复*/ input:checked ~ span{ display:none; } @keyframes clockwise{/*顺时针旋转*/ 0%{ background-position:0px 0px; } 100%{ background-position:-8192px 0px; } } .anticlockwise:hover ~ .rotate{ animation:anticlockwise 1s steps(30) infinite; } .clockwise:hover ~ .rotate{ animation:clockwise 1s steps(30) infinite; } @keyframes anticlockwise{/*逆时针旋转*/ 0%{ background-position:-8192px 0px; } 100%{ background-position:0px 0px; } } </style> </head> <body> <!--选中自动播放--> <input id="auto" class="auto" type="checkbox" checked / > <label class="auto-rotate" for="auto">Auto &#x21bb;</label><br/> <!-- 右箭头 --> <span class="anticlockwise">&#x2190;</span> <!-- 左箭头 --> <span class="clockwise">&#x2192;</span> <div class="rotate"></div> </body> </html>

 

转载于:https://www.cnblogs.com/jikaiyang/p/5747575.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值