今天给大家分享一款html5和css3动画排列人物头像演示。这款实例页面初始时,只有中间的美女图,然后出现微笑图,紧接着出现小的人物图,慢慢的以动画的形式排列到页面中形成一个圆环。效果图如下:

一款利用html5和css3动画排列人物头像的实例演示_html5教程技巧-LMLPHP

  实现的代码。

  html代码:

XML/HTML Code复制内容到剪贴板
  1. <div class='stage'>
  2. <div class='image'>
  3. <img src="https://pbs.twimg.com/profile_images/529224080751202304/UNLt5nUZ_400x400.jpeg">
  4. <div class='smiley'>
  5. <svg width="30px" height="30px">
  6. <path fill="#effedd" d="M15,0C6.7,0,0,6.7,0,15c0,8.3,6.7,15,15,15s15-6.7,15-15C30,6.7,23.3,0,15,0z M20.5,8c1.4,0,2.5,1.1,2.5,2.5c0,1.4-1.1,2.5-2.5,2.5S18,11.9,18,10.5C18,9.1,19.1,8,20.5,8z M10.5,8c1.4,0,2.5,1.1,2.5,2.5c0,1.4-1.1,2.5-2.5,2.5S8,11.9,8,10.5C8,9.1,9.1,8,10.5,8z M15,26c-5,0-9-4-9-9h3c0,3.3,2.7,6,6,6s6-2.7,6-6h3C24,22,20,26,15,26z" />svg>
  7. div>
  8. div>
  9. <figure class='avatar'>
  10. figure>
  11. <figure class='avatar'>
  12. figure>
  13. <figure class='avatar'>
  14. figure>
  15. <figure class='avatar'>
  16. figure>
  17. <figure class='avatar'>
  18. figure>
  19. <figure class='avatar'>
  20. figure>
  21. <figure class='avatar'>
  22. figure>
  23. <figure class='avatar'>
  24. figure>
  25. div>

  css3代码:

CSS Code复制内容到剪贴板
  1. .stage {
  2. position: absolute;
  3. top: 0;
  4. rightright: 0;
  5. bottombottom: 0;
  6. left: 0;
  7. margin: auto;
  8. height: 460px;
  9. width: 480px;
  10. }
  11. .avatar {
  12. position: absolute;
  13. top: 0;
  14. rightright: 0;
  15. bottombottom: 0;
  16. left: 0;
  17. margin: auto;
  18. height: 64px;
  19. width: 64px;
  20. background-repeat: no-repeat;
  21. background-size: cover;
  22. border-radius: 50%;
  23. -webkit-transform-origin: center;
  24. -ms-transform-origin: center;
  25. transform-origin: center;
  26. }
  27. .avatar:before {
  28. content: '';
  29. position: absolute;
  30. top: -8%;
  31. rightright: -8%;
  32. height: 17.06667px;
  33. width: 17.06667px;
  34. background: #bec4bc;
  35. border-radius: 50%;
  36. border: 3px solid white;
  37. }
  38. .avatar:nth-of-type(1) {
  39. -webkit-animation: ani1 2s 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  40. animation: ani1 2s 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  41. }
  42. @-webkit-keyframes ani1 {
  43. 0%, 20% {
  44. -webkit-transform: rotate(45deg) translate(0) rotate(-45deg);
  45. transform: rotate(45deg) translate(0) rotate(-45deg);
  46. }
  47. 34%, 100% {
  48. -webkit-transform: rotate(45deg) translate(208px) rotate(-45deg);
  49. transform: rotate(45deg) translate(208px) rotate(-45deg);
  50. }
  51. }
  52. @keyframes ani1 {
  53. 0%, 20% {
  54. -webkit-transform: rotate(45deg) translate(0) rotate(-45deg);
  55. transform: rotate(45deg) translate(0) rotate(-45deg);
  56. }
  57. 34%, 100% {
  58. -webkit-transform: rotate(45deg) translate(208px) rotate(-45deg);
  59. transform: rotate(45deg) translate(208px) rotate(-45deg);
  60. }
  61. }
  62. .avatar:nth-of-type(2) {
  63. -webkit-animation: ani2 2s 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  64. animation: ani2 2s 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  65. }
  66. @-webkit-keyframes ani2 {
  67. 0%, 20% {
  68. -webkit-transform: rotate(90deg) translate(0) rotate(-90deg);
  69. transform: rotate(90deg) translate(0) rotate(-90deg);
  70. }
  71. 34%, 100% {
  72. -webkit-transform: rotate(90deg) translate(208px) rotate(-90deg);
  73. transform: rotate(90deg) translate(208px) rotate(-90deg);
  74. }
  75. }
  76. @keyframes ani2 {
  77. 0%, 20% {
  78. -webkit-transform: rotate(90deg) translate(0) rotate(-90deg);
  79. transform: rotate(90deg) translate(0) rotate(-90deg);
  80. }
  81. 34%, 100% {
  82. -webkit-transform: rotate(90deg) translate(208px) rotate(-90deg);
  83. transform: rotate(90deg) translate(208px) rotate(-90deg);
  84. }
  85. }
  86. .avatar:nth-of-type(3) {
  87. -webkit-animation: ani3 2s 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  88. animation: ani3 2s 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  89. }
  90. @-webkit-keyframes ani3 {
  91. 0%, 20% {
  92. -webkit-transform: rotate(135deg) translate(0) rotate(-135deg);
  93. transform: rotate(135deg) translate(0) rotate(-135deg);
  94. }
  95. 34%, 100% {
  96. -webkit-transform: rotate(135deg) translate(208px) rotate(-135deg);
  97. transform: rotate(135deg) translate(208px) rotate(-135deg);
  98. }
  99. }
  100. @keyframes ani3 {
  101. 0%, 20% {
  102. -webkit-transform: rotate(135deg) translate(0) rotate(-135deg);
  103. transform: rotate(135deg) translate(0) rotate(-135deg);
  104. }
  105. 34%, 100% {
  106. -webkit-transform: rotate(135deg) translate(208px) rotate(-135deg);
  107. transform: rotate(135deg) translate(208px) rotate(-135deg);
  108. }
  109. }
  110. .avatar:nth-of-type(4) {
  111. -webkit-animation: ani4 2s 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  112. animation: ani4 2s 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  113. }
  114. @-webkit-keyframes ani4 {
  115. 0%, 20% {
  116. -webkit-transform: rotate(180deg) translate(0) rotate(-180deg);
  117. transform: rotate(180deg) translate(0) rotate(-180deg);
  118. }
  119. 34%, 100% {
  120. -webkit-transform: rotate(180deg) translate(208px) rotate(-180deg);
  121. transform: rotate(180deg) translate(208px) rotate(-180deg);
  122. }
  123. }
  124. @keyframes ani4 {
  125. 0%, 20% {
  126. -webkit-transform: rotate(180deg) translate(0) rotate(-180deg);
  127. transform: rotate(180deg) translate(0) rotate(-180deg);
  128. }
  129. 34%, 100% {
  130. -webkit-transform: rotate(180deg) translate(208px) rotate(-180deg);
  131. transform: rotate(180deg) translate(208px) rotate(-180deg);
  132. }
  133. }
  134. .avatar:nth-of-type(5) {
  135. -webkit-animation: ani5 2s 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  136. animation: ani5 2s 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  137. }
  138. @-webkit-keyframes ani5 {
  139. 0%, 20% {
  140. -webkit-transform: rotate(225deg) translate(0) rotate(-225deg);
  141. transform: rotate(225deg) translate(0) rotate(-225deg);
  142. }
  143. 34%, 100% {
  144. -webkit-transform: rotate(225deg) translate(208px) rotate(-225deg);
  145. transform: rotate(225deg) translate(208px) rotate(-225deg);
  146. }
  147. }
  148. @keyframes ani5 {
  149. 0%, 20% {
  150. -webkit-transform: rotate(225deg) translate(0) rotate(-225deg);
  151. transform: rotate(225deg) translate(0) rotate(-225deg);
  152. }
  153. 34%, 100% {
  154. -webkit-transform: rotate(225deg) translate(208px) rotate(-225deg);
  155. transform: rotate(225deg) translate(208px) rotate(-225deg);
  156. }
  157. }
  158. .avatar:nth-of-type(6) {
  159. -webkit-animation: ani6 2s 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  160. animation: ani6 2s 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  161. }
  162. @-webkit-keyframes ani6 {
  163. 0%, 20% {
  164. -webkit-transform: rotate(270deg) translate(0) rotate(-270deg);
  165. transform: rotate(270deg) translate(0) rotate(-270deg);
  166. }
  167. 34%, 100% {
  168. -webkit-transform: rotate(270deg) translate(208px) rotate(-270deg);
  169. transform: rotate(270deg) translate(208px) rotate(-270deg);
  170. }
  171. }
  172. @keyframes ani6 {
  173. 0%, 20% {
  174. -webkit-transform: rotate(270deg) translate(0) rotate(-270deg);
  175. transform: rotate(270deg) translate(0) rotate(-270deg);
  176. }
  177. 34%, 100% {
  178. -webkit-transform: rotate(270deg) translate(208px) rotate(-270deg);
  179. transform: rotate(270deg) translate(208px) rotate(-270deg);
  180. }
  181. }
  182. .avatar:nth-of-type(7) {
  183. -webkit-animation: ani7 2s 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  184. animation: ani7 2s 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  185. }
  186. @-webkit-keyframes ani7 {
  187. 0%, 20% {
  188. -webkit-transform: rotate(315deg) translate(0) rotate(-315deg);
  189. transform: rotate(315deg) translate(0) rotate(-315deg);
  190. }
  191. 34%, 100% {
  192. -webkit-transform: rotate(315deg) translate(208px) rotate(-315deg);
  193. transform: rotate(315deg) translate(208px) rotate(-315deg);
  194. }
  195. }
  196. @keyframes ani7 {
  197. 0%, 20% {
  198. -webkit-transform: rotate(315deg) translate(0) rotate(-315deg);
  199. transform: rotate(315deg) translate(0) rotate(-315deg);
  200. }
  201. 34%, 100% {
  202. -webkit-transform: rotate(315deg) translate(208px) rotate(-315deg);
  203. transform: rotate(315deg) translate(208px) rotate(-315deg);
  204. }
  205. }
  206. .avatar:nth-of-type(8) {
  207. -webkit-animation: ani8 2s 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  208. animation: ani8 2s 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  209. }
  210. @-webkit-keyframes ani8 {
  211. 0%, 20% {
  212. -webkit-transform: rotate(360deg) translate(0) rotate(-360deg);
  213. transform: rotate(360deg) translate(0) rotate(-360deg);
  214. }
  215. 34%, 100% {
  216. -webkit-transform: rotate(360deg) translate(208px) rotate(-360deg);
  217. transform: rotate(360deg) translate(208px) rotate(-360deg);
  218. }
  219. }
  220. @keyframes ani8 {
  221. 0%, 20% {
  222. -webkit-transform: rotate(360deg) translate(0) rotate(-360deg);
  223. transform: rotate(360deg) translate(0) rotate(-360deg);
  224. }
  225. 34%, 100% {
  226. -webkit-transform: rotate(360deg) translate(208px) rotate(-360deg);
  227. transform: rotate(360deg) translate(208px) rotate(-360deg);
  228. }
  229. }
  230. .avatar:nth-of-type(4):before, .avatar:nth-of-type(2):before {
  231. -webkit-animation: bounce 3s 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  232. animation: bounce 3s 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 1.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  233. }
  234. .avatar:nth-of-type(7):before {
  235. -webkit-animation: bounce 3s 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  236. animation: bounce 3s 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  237. }
  238. .avatar:nth-of-type(3):before {
  239. -webkit-animation: bounce 3s 2.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 2.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  240. animation: bounce 3s 2.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 2.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  241. }
  242. .avatar:nth-of-type(1):before {
  243. -webkit-animation: bounce 3s 3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  244. animation: bounce 3s 3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  245. }
  246. .avatar:nth-of-type(6):before {
  247. -webkit-animation: bounce 3s 3.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  248. animation: bounce 3s 3.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  249. }
  250. .avatar:nth-of-type(5):before {
  251. -webkit-animation: bounce 3s 3.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  252. animation: bounce 3s 3.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 3.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  253. }
  254. .avatar:nth-of-type(8):before {
  255. -webkit-animation: bounce 3s 4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  256. animation: bounce 3s 4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, colorchange 1s 4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  257. }
  258. .image {
  259. position: absolute;
  260. top: 0;
  261. rightright: 0;
  262. bottombottom: 0;
  263. left: 0;
  264. margin: auto;
  265. height: 220px;
  266. width: 220px;
  267. }
  268. .image img {
  269. position: relative;
  270. height: 220px;
  271. width: 220px;
  272. border-radius: 50%;
  273. z-index: 1;
  274. }
  275. .image:before {
  276. position: absolute;
  277. top: 0;
  278. rightright: 0;
  279. bottombottom: 0;
  280. left: 0;
  281. margin: auto;
  282. content: '';
  283. height: 100%;
  284. width: 100%;
  285. background: #f9fff7;
  286. border: 3px solid #e7f5d1;
  287. border-radius: 50%;
  288. -webkit-animation: pulse 1s 1.4s ease-out;
  289. animation: pulse 1s 1.4s ease-out;
  290. -webkit-animation-iteration-count: 3;
  291. animation-iteration-count: 3;
  292. }
  293. .image .smiley {
  294. position: absolute;
  295. top: -8px;
  296. rightright: -8px;
  297. height: 64px;
  298. width: 64px;
  299. background: #b5e763;
  300. border-radius: 50%;
  301. border: 5px solid white;
  302. -webkit-animation: bounce 5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  303. animation: bounce 5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  304. -webkit-transform-origin: center;
  305. -ms-transform-origin: center;
  306. transform-origin: center;
  307. z-index: 1;
  308. }
  309. .image .smiley svg {
  310. position: absolute;
  311. top: 0;
  312. rightright: 0;
  313. bottombottom: 0;
  314. left: 0;
  315. margin: auto;
  316. -webkit-animation: bounce 5s 0.075s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  317. animation: bounce 5s 0.075s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  318. }
  319. @-webkit-keyframes bounce {
  320. 0% {
  321. -webkit-transform: scale(0);
  322. transform: scale(0);
  323. }
  324. 5% {
  325. -webkit-transform: scale(1.5);
  326. transform: scale(1.5);
  327. }
  328. 10%, 100% {
  329. -webkit-transform: scale(1);
  330. transform: scale(1);
  331. }
  332. }
  333. @keyframes bounce {
  334. 0% {
  335. -webkit-transform: scale(0);
  336. transform: scale(0);
  337. }
  338. 5% {
  339. -webkit-transform: scale(1.5);
  340. transform: scale(1.5);
  341. }
  342. 10%, 100% {
  343. -webkit-transform: scale(1);
  344. transform: scale(1);
  345. }
  346. }
  347. @-webkit-keyframes pulse {
  348. 0% {
  349. -webkit-transform: scale(0.1, 0.1);
  350. transform: scale(0.1, 0.1);
  351. opacity: 0.0;
  352. }
  353. 50% {
  354. opacity: 1.0;
  355. }
  356. 100% {
  357. -webkit-transform: scale(3);
  358. transform: scale(3);
  359. opacity: 0.0;
  360. }
  361. }
  362. @keyframes pulse {
  363. 0% {
  364. -webkit-transform: scale(0.1, 0.1);
  365. transform: scale(0.1, 0.1);
  366. opacity: 0.0;
  367. }
  368. 50% {
  369. opacity: 1.0;
  370. }
  371. 100% {
  372. -webkit-transform: scale(3);
  373. transform: scale(3);
  374. opacity: 0.0;
  375. }
  376. }
  377. @-webkit-keyframes colorchange {
  378. 0% {
  379. background: #bec4bc;
  380. }
  381. 100% {
  382. background: #b5e763;
  383. }
  384. }
  385. @keyframes colorchange {
  386. 0% {
  387. background: #bec4bc;
  388. }
  389. 100% {
  390. background: #b5e763;
  391. }
  392. }
  393. .avatar:nth-of-type(1) {
  394. background-image: url("128.jpg");
  395. }
  396. .avatar:nth-of-type(2) {
  397. background-image: url("rasagy.jpg");
  398. }
  399. .avatar:nth-of-type(3) {
  400. background-image: url("geeftvorm.jpg");
  401. }
  402. .avatar:nth-of-type(4) {
  403. background-image: url("VinThomas.jpg");
  404. }
  405. .avatar:nth-of-type(5) {
  406. background-image: url("ladylexy.jpg");
  407. }
  408. .avatar:nth-of-type(6) {
  409. background-image: url("claudioguglieri.jpg");
  410. }
  411. .avatar:nth-of-type(7) {
  412. background-image: url("jina.jpg");
  413. }
  414. .avatar:nth-of-type(8) {
  415. background-image: url("peterme.jpg");
  416. }

  好了以上就是今天介绍的html5和css3动画排列人物头像代码演示,谢谢阅读,希望能帮到大家,请继续关注脚本之家,我们会努力分享更多优秀的文章。

09-16 18:15