wave.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="wave-wrap waveAnimation">
  3. <view class="waveWrapperInner bgTop"><view class="wave waveTop"></view></view>
  4. <view class="waveWrapperInner bgMiddle"><view class="wave waveMiddle"></view></view>
  5. <view class="waveWrapperInner bgBottom"><view class="wave waveBottom"></view></view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'wave',
  11. props: {
  12. height: {
  13. type: String,
  14. default: '35rpx'
  15. }
  16. }
  17. };
  18. </script>
  19. <style lang="scss" scoped>
  20. .wave-wrap {
  21. overflow: hidden;
  22. position: absolute;
  23. left: 0;
  24. right: 0;
  25. bottom: 0;
  26. top: 0;
  27. margin: auto;
  28. }
  29. .waveWrapperInner {
  30. position: absolute;
  31. width: 100%;
  32. overflow: hidden;
  33. height: 100%;
  34. }
  35. .wave {
  36. position: absolute;
  37. left: 0;
  38. width: 200%;
  39. height: 100%;
  40. background-repeat: repeat no-repeat;
  41. background-position: 0 bottom;
  42. transform-origin: center bottom;
  43. }
  44. .bgTop {
  45. opacity: 0.4;
  46. }
  47. .waveTop {
  48. background-size: 50% 45px;
  49. background-image: url('~@/static/wave/wave-1.png');
  50. }
  51. .waveAnimation .waveTop {
  52. animation: move_wave 4s linear infinite;
  53. }
  54. @keyframes move_wave {
  55. 0% {
  56. transform: translateX(0) translateZ(0) scaleY(1);
  57. }
  58. 50% {
  59. transform: translateX(-25%) translateZ(0) scaleY(1);
  60. }
  61. 100% {
  62. transform: translateX(-50%) translateZ(0) scaleY(1);
  63. }
  64. }
  65. .bgMiddle {
  66. opacity: 0.6;
  67. }
  68. .waveMiddle {
  69. background-size: 50% 40px;
  70. background-image: url('~@/static/wave/wave-2.png');
  71. }
  72. .waveAnimation .waveMiddle {
  73. animation: move_wave 3.5s linear infinite;
  74. }
  75. .bgBottom {
  76. opacity: 0.95;
  77. }
  78. .waveBottom {
  79. background-size: 50% 35px;
  80. background-image: url('~@/static/wave/wave-1.png');
  81. }
  82. .waveAnimation .waveBottom {
  83. animation: move_wave 2s linear infinite;
  84. }
  85. </style>