纯CSS发抖 

当您在 @keyframes 中创建动画时,请把它捆绑到某个选择器,否则不会产生动画效果。

通过规定至少以下两项 CSS3 动画属性,即可将动画绑定到选择器:

  • 规定动画的名称
  • 规定动画的时长

html

<section class="section carrot" style="position: absolute;">
<h1>抖动方式</h1>
<ul class="previews">
<li>
<i class="preview-item shake">
Bs
<span class="flip">
</span>
</i>
<p class="preview-desc">基本抖动</p>
</li> <li>
<i class="preview-item shake shake-constant">

<span class="flip"></span>
</i>
<p class="preview-desc">抖动不停</p>
</li>
</ul>
</section>

css

/*绕着图片那个点旋转*/
.shake { display: inline-block;
-webkit-transform-origin: center center;
-ms-transform-origin: center center;
transform-origin: center center;
}
/*基本抖动*/
.shake:hover { -webkit-animation-name: shake-base;
-ms-animation-name: shake-base;
animation-name: shake-base;
-webkit-animation-duration: 100ms;
-ms-animation-duration: 100ms;
animation-duration: 100ms;
-webkit-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
-ms-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-delay: 0s;
-ms-animation-delay: 0s;
animation-delay: 0s;
-webkit-animation-play-state: running;
-ms-animation-play-state: running;
animation-play-state: running;
}
/*抖动不停*/
.shake.shake-constant {
-webkit-animation-name: shake-base;
-ms-animation-name: shake-base;
animation-name: shake-base;
-webkit-animation-duration: 100ms;
-ms-animation-duration: 100ms;
animation-duration: 100ms;
-webkit-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
-ms-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
-webkit-animation-delay: 0s;
-ms-animation-delay: 0s;
animation-delay: 0s;
-webkit-animation-play-state: running;
-ms-animation-play-state: running;
animation-play-state: running;
}
/*keyframes 动画*/
@-webkit-keyframes shake-base {
0% { -webkit-transform: translate(0px, 0px) rotate(0deg); }
2% { -webkit-transform: translate(-0.5px, 1.5px) rotate(0.5deg); }
4% { -webkit-transform: translate(-0.5px, 1.5px) rotate(-0.5deg); }
6% { -webkit-transform: translate(-2.5px, -1.5px) rotate(0.5deg); }
8% { -webkit-transform: translate(-2.5px, -2.5px) rotate(-1.5deg); }
10% { -webkit-transform: translate(1.5px, 1.5px) rotate(-1.5deg); }
12% { -webkit-transform: translate(-2.5px, -0.5px) rotate(-0.5deg); }
14% { -webkit-transform: translate(1.5px, -2.5px) rotate(-0.5deg); }
16% { -webkit-transform: translate(0.5px, 1.5px) rotate(0.5deg); }
18% { -webkit-transform: translate(-2.5px, -0.5px) rotate(0.5deg); }
20% { -webkit-transform: translate(-0.5px, -0.5px) rotate(-1.5deg); }
22% { -webkit-transform: translate(-2.5px, -1.5px) rotate(-1.5deg); }
24% { -webkit-transform: translate(-1.5px, -2.5px) rotate(-1.5deg); }
26% { -webkit-transform: translate(0.5px, -0.5px) rotate(-1.5deg); }
28% { -webkit-transform: translate(-0.5px, -1.5px) rotate(-0.5deg); }
30% { -webkit-transform: translate(-2.5px, 1.5px) rotate(0.5deg); }
32% { -webkit-transform: translate(-2.5px, -2.5px) rotate(-0.5deg); }
34% { -webkit-transform: translate(-1.5px, 0.5px) rotate(-1.5deg); }
36% { -webkit-transform: translate(1.5px, -1.5px) rotate(-1.5deg); }
38% { -webkit-transform: translate(0.5px, -0.5px) rotate(-0.5deg); }
40% { -webkit-transform: translate(-0.5px, 0.5px) rotate(0.5deg); }
42% { -webkit-transform: translate(0.5px, -2.5px) rotate(-0.5deg); }
44% { -webkit-transform: translate(0.5px, -2.5px) rotate(-0.5deg); }
46% { -webkit-transform: translate(-1.5px, 1.5px) rotate(-1.5deg); }
48% { -webkit-transform: translate(0.5px, -2.5px) rotate(-0.5deg); }
50% { -webkit-transform: translate(-1.5px, -0.5px) rotate(-1.5deg); }
52% { -webkit-transform: translate(-2.5px, -0.5px) rotate(-1.5deg); }
54% { -webkit-transform: translate(1.5px, 0.5px) rotate(-1.5deg); }
56% { -webkit-transform: translate(0.5px, 0.5px) rotate(-1.5deg); }
58% { -webkit-transform: translate(0.5px, 1.5px) rotate(-0.5deg); }
60% { -webkit-transform: translate(-0.5px, -2.5px) rotate(-0.5deg); }
62% { -webkit-transform: translate(-2.5px, -1.5px) rotate(-0.5deg); }
64% { -webkit-transform: translate(-1.5px, 0.5px) rotate(0.5deg); }
66% { -webkit-transform: translate(0.5px, -0.5px) rotate(-1.5deg); }
68% { -webkit-transform: translate(-1.5px, -0.5px) rotate(-1.5deg); }
70% { -webkit-transform: translate(-0.5px, -2.5px) rotate(-1.5deg); }
72% { -webkit-transform: translate(-2.5px, -0.5px) rotate(-1.5deg); }
74% { -webkit-transform: translate(-2.5px, 0.5px) rotate(0.5deg); }
76% { -webkit-transform: translate(1.5px, -1.5px) rotate(-1.5deg); }
78% { -webkit-transform: translate(1.5px, -2.5px) rotate(0.5deg); }
80% { -webkit-transform: translate(-2.5px, -2.5px) rotate(-0.5deg); }
82% { -webkit-transform: translate(-2.5px, -1.5px) rotate(0.5deg); }
84% { -webkit-transform: translate(0.5px, -2.5px) rotate(-0.5deg); }
86% { -webkit-transform: translate(-2.5px, 0.5px) rotate(-0.5deg); }
88% { -webkit-transform: translate(-2.5px, -0.5px) rotate(-0.5deg); }
90% { -webkit-transform: translate(-1.5px, -1.5px) rotate(-1.5deg); }
92% { -webkit-transform: translate(-0.5px, -1.5px) rotate(-0.5deg); }
94% { -webkit-transform: translate(0.5px, -0.5px) rotate(-0.5deg); }
96% { -webkit-transform: translate(-2.5px, -2.5px) rotate(0.5deg); }
98% { -webkit-transform: translate(-0.5px, 1.5px) rotate(-0.5deg); } }


抖动方式

鼠标放上去 开始抖动

  • Bs

    基本抖动

  • 抖动不停

CSS发抖的更多相关文章

  1. 哇塞!HTML5 实现的雨滴效果 CSS发抖

    http://dreamsky.github.io/main/blog/rainy-day/ Rainy Day – 哇塞! HTML5 实现的雨滴效果 http://www.webhek.com/m ...

  2. Matplotlib数据可视化(3):文本与轴

      在一幅图表中,文本.坐标轴和图像的是信息传递的核心,对着三者的设置是作图这最为关心的内容,在上一篇博客中虽然列举了一些设置方法,但没有进行深入介绍,本文以围绕如何对文本和坐标轴进行设置展开(对图像 ...

  3. CSS的未来

    仅供参考 前言 完成<CSS核心技术与实战>这本书,已有一个多月了,而这篇文章原本是打算写在那本书里面的,但本章讲解的内容,毕竟属于CSS未来的范畴,而这一切都还不能够确定下来,所以这一章 ...

  4. 前端极易被误导的css选择器权重计算及css内联样式的妙用技巧

    记得大学时候,专业课的网页设计书籍里面讲过css选择器权重的计算:id是100,class是10,html标签是5等等,然后全部加起来的和进行比较... 我只想说:真是误人子弟,害人不浅! 最近,在前 ...

  5. 前端css兼容性与易混淆的点

    一.常用的骨灰级清除浮动 .clearfix:after { content: "."; display: block; height:; clear: both; visibil ...

  6. 理解CSS外边距margin

    前面的话   margin是盒模型几个属性中一个非常特殊的属性.简单举几个例子:只有margin不显示当前元素背景,只有margin可以设置为负值,margin和宽高支持auto,以及margin具有 ...

  7. 理解CSS视觉格式化

    前面的话   CSS视觉格式化这个词可能比较陌生,但说起盒模型可能就恍然大悟了.实际上,盒模型只是CSS视觉格式化的一部分.视觉格式化分为块级和行内两种处理方式.理解视觉格式化,可以确定得到的效果是应 ...

  8. 谈谈一些有趣的CSS题目(十二)-- 你该知道的字体 font-family

    开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库

    在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...

随机推荐

  1. Centos安装php提示virtual memory exhausted: Cannot allocate memory

    由于内存不够,需要在php配置的时候./configure最后添加上 --disable-fileinfo >>./configure --prefix= ...........   -- ...

  2. 1009 Enigma

    本题的重点是理解清楚题意并能代码模拟.形式是二战德国密码机,和数据结构.算法联系较少. #include <stdio.h> #include <string.h> int m ...

  3. 启动Activity,传递参数最佳实践

    优化后的好处不言而喻,OtherActivity中所需要的参数都在方法参数中体现,减少了交流询问的成本. (1)MainActivity.java OtherActivity.openActivity ...

  4. C# DateTime类,TimeSpan类

    DateTime类是.Net中用于处理时间类型数据的. 一.字段 MaxValue 表示 DateTime 的最大可能值.此字段为只读. MinValue     表示 DateTime 的最小可能值 ...

  5. TextReader/TextWriter 的类

    TextReader以及TextWriter这两个类,非常有用,很多方法都接受它们作为参数. TextReader有两个子类: StringReader/StringWriter 用于读取字符串: S ...

  6. bzoj1648 [Usaco2006 Dec]Cow Picnic 奶牛野餐

    Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is graz ...

  7. spring-boot+nginx+tomcat+ssl配置笔记

    如果你的tomcat应用需要采用ssl来加强安全性,一种做法是把tomcat配置为支持ssl,另一种做法是用nginx反向代理tomcat,然后把nginx配置为https访问,并且nginx与tom ...

  8. hdu 3874 Necklace(bit树+事先对查询区间右端点排序)

    Mery has a beautiful necklace. The necklace is made up of N magic balls. Each ball has a beautiful v ...

  9. OpenGL进阶(十一) - GLSL4.x中的数据传递

    in out 对于 vertex shader,每个顶点都会包含一次,它的主要工作时处理关于定点的数据,然后把结果传递到管线的下个阶段. 以前版本的GLSL,数据会通过一些内建变量,比如gl_Vert ...

  10. Selenium模块化

    概述 高内聚低耦合是软件设计的一个基本原则. 内聚:从功能角度来度量模块内的联系,一个好的内聚模块应当恰好做一件事.它描述的是模块内的功能联系. 耦合:各模块之间相互连接的一种度量,耦合强弱取决于模块 ...