html5+css3图片旋转特效

<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">

  1. #img1{
  2. width:280px;
  3. height: 279px;
  4. border-radius:140px;
  5. -webkit-animation:run 6s linear 0s infinite;
  6. }
  7. #img1:hover{
  8. -webkit-animation-play-state:paused;
  9. }
  10. @-webkit-keyframes run{
  11. from{
  12. -webkit-transform:rotate(0deg);
  13. }
  14. to{
  15. -webkit-transform:rotate(360deg);
  16. }
  17. }
  18. </style>

</head>

<body>
<div ><img id="img1" src="C:\Users\hp\Desktop\1.jpg" /></div>
</body>
</html>
1.id为img1的图片通过设置圆角使图片为圆形显示,src为路径

      1. 代码中关键的部分是怎样使得图片无限转动。 我们可以使用 -webkit-animation 和 @-webkit-keyframes 组合使用来完成。
        -webkit-animation 是一个复合属性,定义如下:
        -webkit-animation: name duration timing-function delay iteration_count direction;
        name: 是 @-webkit-keyframes 中需要指定的方法,用来执行动画。
        duration: 动画一个周期执行的时长。
        timing-function: 动画执行的效果,可以是线性的,也可以是”快速进入慢速出来”等。
        delay: 动画延时执行的时长。
        iteration_count: 动画循环执行次数,如果是infinite,则无限执行。
        direction: 动画执行方向。
      2. @-webkit-keyframes 中的from和to 两个属性,就是指定动画执行的初始值和结束值。
      3. -webkit-animation-play-state:paused; 暂停动画的执行。

猜你喜欢

转载自www.cnblogs.com/ming-blogs/p/10289058.html