资讯专栏INFORMATION COLUMN

css动画Demo---水波动画和边框动画

dongfangyiyu / 2414人阅读

摘要:先上效果图水波动画边框动画水波动画实现代码水波动画边框动画实现代码边框动画

先上效果图:

  水波动画:

  

  边框动画:

1.水波动画

  实现代码

  

</>复制代码

  1. 1 DOCTYPE html>
  2. 2 <html lang="en">
  3. 3 <head>
  4. 4 <meta charset="UTF-8">
  5. 5 <title>水波动画title>
  6. 6 <style>
  7. 7 .water{
  8. 8 width: 50px;
  9. 9 height: 50px;
  10. 10 position: relative;
  11. 11 }
  12. 12 .point{
  13. 13 position: absolute;
  14. 14 border-radius: 50%;
  15. 15 animation:border 2s linear infinite;
  16. 16 }
  17. 17 .point2{
  18. 18 -webkit-animation-delay:.5s;
  19. 19 }
  20. 20 .point3{
  21. 21 -webkit-animation-delay:1s;
  22. 22 }
  23. 23 .point4{
  24. 24 -webkit-animation-delay:1.5s;
  25. 25 }
  26. 26
  27. 27 @keyframes border{
  28. 28 from {
  29. 29 width:0;
  30. 30 height:0;
  31. 31 top:50%;
  32. 32 left:50%;
  33. 33 background-color: rgba(235, 51, 36, 1);
  34. 34 }
  35. 35 to {
  36. 36 width:100%;
  37. 37 height:100%;
  38. 38 top:0;
  39. 39 left:0;
  40. 40 background-color: rgba(235, 51, 36, 0);
  41. 41 }
  42. 42 }
  43. 43 style>
  44. 44 head>
  45. 45 <body>
  46. 46 <div class="water">
  47. 47 <div class="point point1">div>
  48. 48 <div class="point point2">div>
  49. 49 <div class="point point3">div>
  50. 50 <div class="point point4">div>
  51. 51 div>
  52. 52 body>
  53. 53 html>

2.边框动画:

  实现代码

</>复制代码

  1. 1 DOCTYPE html>
  2. 2 <html lang="en">
  3. 3 <head>
  4. 4 <meta charset="UTF-8">
  5. 5 <title>边框动画title>
  6. 6 <style>
  7. 7 .block{
  8. 8 width: 100px;
  9. 9 height: 50px;
  10. 10 position: relative;
  11. 11 background-color: #fcfcfc;
  12. 12 overflow: hidden;
  13. 13 }
  14. 14 .block:before{
  15. 15 content: ";
  16. 16 width: 0;
  17. 17 height: 0;
  18. 18 top: 0;
  19. 19 left: -1px;
  20. 20 display: block;
  21. 21 border-top: 1px solid red;
  22. 22 border-right: 1px solid red;
  23. 23 position: absolute;
  24. 24 z-index: 1;
  25. 25 }
  26. 26 .block:hover:before{
  27. 27 content: ";
  28. 28 width: 100%;
  29. 29 height: 100%;
  30. 30 border-radius: 5px;
  31. 31 animation: border .5s linear 1;
  32. 32 }
  33. 33 .block:after{
  34. 34 content: ";
  35. 35 width: 0;
  36. 36 height: 0;
  37. 37 bottom: 0;
  38. 38 right: -1px;
  39. 39 display: block;
  40. 40 position: absolute;
  41. 41 z-index: 1;
  42. 42 border-bottom: 1px solid red;
  43. 43 border-left: 1px solid red;
  44. 44 }
  45. 45 .block:hover:after{
  46. 46 content: ";
  47. 47 width: 100%;
  48. 48 height: 100%;
  49. 49 border-radius: 5px;
  50. 50 animation: border2 1s linear 1;
  51. 51 }
  52. 52 @keyframes border{
  53. 53 0%{
  54. 54 width: 0;
  55. 55 height: 0;
  56. 56 }
  57. 57 50%{
  58. 58 width: 100%;
  59. 59 height: 0;
  60. 60 }
  61. 61 100%{
  62. 62 width: 100%;
  63. 63 height: 100%;
  64. 64 }
  65. 65
  66. 66 }
  67. 67 @keyframes border2{
  68. 68 0%{
  69. 69 width: 0;
  70. 70 height: 0;
  71. 71 }
  72. 72 50%{
  73. 73 width: 0;
  74. 74 height: 0;
  75. 75 }
  76. 76 75%{
  77. 77 width: 100%;
  78. 78 height: 0;
  79. 79 }
  80. 80 100%{
  81. 81 width: 100%;
  82. 82 height: 100%;
  83. 83 }
  84. 84 }
  85. 85 style>
  86. 86 head>
  87. 87 <body>
  88. 88 <div class="block">div>
  89. 89 body>
  90. 90 html>

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/2156.html

相关文章

  • 前端每日实战:137# 视频演示如何用纯 CSS 创作一个抽象的水波荡漾的动画

    摘要:效果预览按下右侧的点击预览按钮可以在当前页面预览,点击链接可以全屏预览。可交互视频此视频是可以交互的,你可以随时暂停视频,编辑视频中的代码。 showImg(https://segmentfault.com/img/bVbg3CU?w=400&h=301); 效果预览 按下右侧的点击预览按钮可以在当前页面预览,点击链接可以全屏预览。 https://codepen.io/comehop...

    yck 评论0 收藏0
  • 前端每日实战:137# 视频演示如何用纯 CSS 创作一个抽象的水波荡漾的动画

    摘要:效果预览按下右侧的点击预览按钮可以在当前页面预览,点击链接可以全屏预览。可交互视频此视频是可以交互的,你可以随时暂停视频,编辑视频中的代码。 showImg(https://segmentfault.com/img/bVbg3CU?w=400&h=301); 效果预览 按下右侧的点击预览按钮可以在当前页面预览,点击链接可以全屏预览。 https://codepen.io/comehop...

    rottengeek 评论0 收藏0
  • mask-image的应用

    摘要:大概的效果就是被遮罩层与遮罩层不透明的部分重叠的部分是可见的,而遮罩层是不显示的。利用能做出一些不错的效果,比如。想到用这个属性正合适,于是要来了心型图片,拿到设计师导出的文件,用压缩下得到一个。 遮罩层,如果学过Flash的同学应该都听过,跟PS的剪切蒙版差不多。大概的效果就是被遮罩层与遮罩层不透明的部分重叠的部分是可见的,而遮罩层是不显示的。类似于现实世界中一张A4卡纸剪了个洞,我...

    HollisChuang 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<