今天给大家分享一款基于jquery和css3的头像恶搞特效。这款实例中,一个头像在画面中跳舞,头像还有可爱的帽子,单击下面的按钮可以为头像切换不同的帽子。效果图如下:

在线预览   源码下载

实现的代码。

html代码:

  1. <div class="wwiaftm-container">
  2. <div class="base wwiaftm">
  3. <div class="body-1 wwiaftm">
  4. <div class="body-2 wwiaftm">
  5. <div class="hat wwiaftm" style="background-image: url(Mini_Sombrero.png)">
  6. </div>
  7. <div class="head wwiaftm">
  8. <div class="profile">
  9. <img src="head.png">
  10. </div>
  11. </div>
  12. <div class="wwiaftm arm-1 left">
  13. <div class="wwiaftm arm-2 left">
  14. <div class="wwiaftm fingers">
  15. </div>
  16. </div>
  17. </div>
  18. <div class="wwiaftm arm-1 right">
  19. <div class="wwiaftm arm-2 right">
  20. <div class="wwiaftm fingers">
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="switch-container">
  29. <button id="hat-switch">
  30. Hat Me!</button>
  31. </div>
  32. <script src='jquery.min.js'></script>
  33. <script>        var hats = Array(
  34. 'Mini_Sombrero.png', 'med.png',
  35. 'svg.med.png',
  36. 'cartoon-cowboy-8.gif',
  37. '1313955-witch-hat-002_92007.gif',
  38. 'hat_mario_101401.jpg',
  39. 'vector-hat-design1.jpg'
  40. );
  41. $('#hat-switch').on('click', function (e) {
  42. e.preventDefault();
  43. var hat = hats[Math.floor(Math.random() * hats.length)];
  44. $('.hat').css('background-image', 'url(' + hat + ')');
  45. });
  46. //@ sourceURL=pen.js
  47. </script>

css3代码:

  1. .wwiaftm-container {
  2. position: relative;
  3. width: 200px;
  4. height: 275px;
  5. margin: auto;
  6. padding-top: 100px;
  7. }
  8. .profile {
  9. border-radius: 100px;
  10. overflow: hidden;
  11. }
  12. .wwiaftm {
  13. background: #48e0a4;
  14. position: absolute;
  15. margin: auto;
  16. border-radius: 25%;
  17. }
  18. .body-1 {
  19. background-repeat: no-repeat;
  20. background-position: center;
  21. background-size: 70%;
  22. }
  23. .base {
  24. width: 60px;
  25. height: 80px;
  26. bottom: 0;
  27. left: 0;
  28. right: 0;
  29. }
  30. .hat {
  31. top: -120px;
  32. height: 80px;
  33. width: 100px;
  34. -webkit-transform-origin: 50% 100%;
  35. transform-origin: 50% 100%;
  36. -webkit-transform: rotate3d(0,0,1,0deg);
  37. transform: rotate3d(0,0,1,0deg);
  38. background-repeat: no-repeat;
  39. background-position: center;
  40. transparent;
  41. background-size: 100%;
  42. z-index: 10 !important;
  43. }
  44. .body-1, .body-2, .head {
  45. top: -60px;
  46. height: 80px;
  47. width: 60px;
  48. -webkit-transform-origin: 50% 100%;
  49. transform-origin: 50% 100%;
  50. -webkit-transform: rotate3d(0,0,1,0deg);
  51. transform: rotate3d(0,0,1,0deg);
  52. }
  53. .body-1 {
  54. -webkit-animation: flail 4s linear infinite;
  55. animation: flail 4s linear infinite;
  56. }
  57. .body-2 {
  58. -webkit-animation: flail 3s linear infinite;
  59. animation: flail 3s linear infinite;
  60. }
  61. .head, .hat {
  62. -webkit-animation: flail 2s linear infinite;
  63. animation: flail 2s linear infinite;
  64. z-index: 1;
  65. }
  66. .head .eye, .head .mouth {
  67. height: 20%;
  68. width: 15%;
  69. background: black;
  70. position: absolute;
  71. top: 25%;
  72. }
  73. .head .eye.right {
  74. right: 20%;
  75. }
  76. .head .eye.left {
  77. left: 20%;
  78. }
  79. .head .mouth {
  80. width: 70%;
  81. top: 60%;
  82. height: 5%;
  83. left: 0;
  84. right: 0;
  85. margin: auto;
  86. }
  87. .arm-1, .arm-2 {
  88. position: absolute;
  89. width: 50px;
  90. height: 20px;
  91. right: 90%;
  92. top: 25%;
  93. -webkit-animation: flail 1s linear infinite;
  94. animation: flail 1s linear infinite;
  95. -webkit-transform-origin: 100% 50%;
  96. transform-origin: 100% 50%;
  97. }
  98. .arm-1.right, .arm-2.right {
  99. left: 90%;
  100. -webkit-transform-origin: 0% 50%;
  101. transform-origin: 0% 50%;
  102. }
  103. .arm-1 .arm-2 {
  104. -webkit-animation: flail .5s linear infinite;
  105. animation: flail .5s linear infinite;
  106. right: 80%;
  107. top: auto;
  108. }
  109. .arm-1 .arm-2.right {
  110. left: 80%;
  111. right: auto;
  112. }
  113. @-webkit-keyframes flail {
  114. 0% {
  115. -webkit-transform: rotate3d(0,0,1,0deg);
  116. }
  117. 25% {
  118. -webkit-transform: rotate3d(0,0,1,50deg);
  119. }
  120. 50% {
  121. -webkit-transform: rotate3d(0,0,1,0deg);
  122. }
  123. 75% {
  124. -webkit-transform: rotate3d(0,0,1,-50deg);
  125. }
  126. 100% {
  127. -webkit-transform: rotate3d(0,0,1,0deg);
  128. }
  129. }
  130. @keyframes flail {
  131. 0% {
  132. transform: rotate3d(0,0,1,0deg);
  133. }
  134. 25% {
  135. transform: rotate3d(0,0,1,50deg);
  136. }
  137. 50% {
  138. transform: rotate3d(0,0,1,0deg);
  139. }
  140. 75% {
  141. transform: rotate3d(0,0,1,-50deg);
  142. }
  143. 100% {
  144. transform: rotate3d(0,0,1,0deg);
  145. }
  146. }
  147. .switch-container {
  148. text-align: center;
  149. margin-top: 25px;
  150. }
  151. #hat-switch {
  152. text-align: center;
  153. font-size: 24px;
  154. cursor: pointer;
  155. }

一款基于jquery和css3的头像恶搞特效的更多相关文章

  1. 一款基于jquery和css3的响应式二级导航菜单

    今天给大家分享一款基于jquery和css3的响应式二级导航菜单,这款导航是传统的基于顶部,鼠标经过的时候显示二级导航,还采用了当前流行的响应式设计.效果图如下: 在线预览   源码下载 实现的代码. ...

  2. 一款基于jquery和css3实现的摩天轮式分享按钮

    之前分享了很多css3实现的按钮.今天要给大家带来一款基于jquery和css3实现的摩天轮式分享按钮.这款分享按钮页面底部有一个toggle按钮,单击该按钮,摩天轮按钮以动画的形式出现,各个分享按钮 ...

  3. 一款基于jquery的鼠标经过图片列表特效

    今天要给大家推荐一款基于jquery的鼠标经过图片列表特效.当鼠标经过列表图片的时候,图片放大,且有一个半透明的遮罩层随之移动.效果图如下: 在线预览   源码下载 实现的代码 html代码: < ...

  4. 一款基于jquery超炫的图片切换特效

    今天为给大家介绍一款基于jquery超炫的图片切换特效.由百叶窗飞入显示图片.图片消息的时候也是百叶窗渐行渐远.用于图片展示,效果还是非常好,我们一起看下效果图: 在线预览   源码下载 来看下实现的 ...

  5. 一款基于jQuery和CSS3炫酷3D旋转画廊特效插件

    这是一款效果炫酷的jQuery和CSS3 3D旋转画廊特效插件.该3D画廊插件可以通过前后导航按钮来切换图片,效果就像旋转木马一样.它还带有点击放大图片,显示图片标题和用键盘操作等功能. 在线预览   ...

  6. 4款基于jquery的列表图标动画切换特效

    网页中列表图标随处可见,特别是移动网页上,基本上的导航都采用了列表图标.今天给大家分享4款基于juqery的列表图标和关闭图标的动画切换特效.喜欢的网友赶紧收藏吧. 在线预览   源码下载 实现的代码 ...

  7. 10款基于jquery的web前端动画特效

    1.jQuery横向手风琴图片切换动画 之前我们为大家分享过很多款基于jQuery和CSS3的手风琴菜单和手风琴焦点图插件,比如CSS3响应式垂直手风琴菜单和jQuery横向手风琴图片展示插件.今天要 ...

  8. 基于jQuery 3D旋转明星人物展示特效

    分享一款基于jQuery 3D旋转明星人物展示特效.这是一款来自百度换肤活动的明星旋转展示效果.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class=&quo ...

  9. 30款基于 jQuery & CSS3 的加载动画和进度条插件

    我们所生活每一天看到的新技术或新设计潮流的兴起,Web 开发正处在上升的时代.HTML5 & CSS3 技术的发展让 Web 端可以实现的功能越来越强大. 加载动画和进度条使网站更具吸引力.该 ...

随机推荐

  1. Android 启动、绘制、显示过程

    Activity 启动过程: startActivity()-> Instrumentation.execStartActivity()-> Binder->ActivityMana ...

  2. SQL Server 2008开启sa账户以及如何用JDBC进行连接

    做实验需要用Java与SQL Server连接,因为使用的 SQL 2008 Express Edition 是基于 Visual Studio2010 安装包安装时一起安装的,所以为了方便数据库的操 ...

  3. [nginx]编译安装及安全优化

    nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...

  4. 【小白的CFD之旅】22 好网格与坏网格

    网格疏密网格形状其他的一些问题小白的总结郑重申明 网格的作用如此重要,以至于小白纠结了很久.小白知道网格划分过程很大程度上受制于计算资源的限制,但小白还是不太明白,如果计算资源非常充足,不用顾忌资源限 ...

  5. Gartner 2018新技术成熟度曲线

    https://blog.csdn.net/BtB5e6Nsu1g511Eg5XEg/article/details/82047719 近日,Gartner发布了2018年新技术成熟度曲线,首次将生物 ...

  6. [Windows Azure] How to use the Queue Storage Service

    How to use the Queue Storage Service version 1.7 version 2.0 This guide will show you how to perform ...

  7. 【编码】Base64编码

    简述 为什么叫Base64?个人理解是,基础的64个字符. 而它的作用?用基础的(可理解为可安全传输的)64个字符,来表示难以表示的二进制或对程序造成干扰的字符. Base64的编码过程 自行编码分析 ...

  8. 【Android】输入设备配置文件(.idc文件)

    何为idc idc(Input Device Configuration)为输入设备配置文件,它包含设备具体的配置属性,这些属性影响输入设备的行为. 对于touch screen设备,总是需要一个id ...

  9. IntelliJ IDEA 14.1.4破解方法-通过程序根据用户名生成注册码

    将下面的代码拷贝到Eclipse或者其他的开发工具中,在main方法中指定自己的用户名(随意),运行main方法,在控制台即可生成注册码.然后启动IntelliJ IDEA 14.1.4,然后根据提示 ...

  10. Ubuntu 搜狗输入法崩溃 重启办法

    参考:https://www.findhao.net/res/786 打开终端,执行: pidof fcitx | xargs kill fcitx -r 上面两句意思就是kill fcitx的进程再 ...