css3动画实现水波浪效果

无聊写的一个小Demo,方便自己以后使用

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4. <meta charset=“UTF-8”>
  5. <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
  6. <meta http-equiv=“X-UA-Compatible” content=“ie=edge”>
  7. <title>水波浪Demo </title>
  8. </head>
  9. <style>
  10. body {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. #container {
  15. width: 100vw;
  16. height: 100vh;
  17. overflow: hidden;
  18. }
  19. .wave-wrapper{
  20. width: 100%;
  21. height: 80px;
  22. position: relative;
  23. }
  24. .wave {
  25. width: 100%;
  26. height: 60px;
  27. position: absolute;
  28. }
  29. .wave1 {
  30. bottom: 20px;
  31. background: url( ’./img/wave.png’);
  32. background-position: 0 0;
  33. opacity: 0.4;
  34. animation: moveLeft 7s linear infinite;
  35. }
  36. .wave2 {
  37. bottom: 10px;
  38. background: url( ’./img/wave.png’);
  39. background-position: 0 0;
  40. opacity: 0.6;
  41. animation: moveRight 10s linear infinite;
  42. }
  43. .wave3 {
  44. bottom: 0;
  45. background: url( ’./img/wave.png’);
  46. background-position: 0 0;
  47. opacity: 1;
  48. animation: moveLeft 15s linear infinite;
  49. }
  50. .content-wrapper {
  51. width: 100%;
  52. height: calc(100vh - 60px);
  53. background-color: #009fd9;
  54. }
  55. @ keyframes moveLeft {
  56. 0% {
  57. background-position-x: 0;
  58. }
  59. 100% {
  60. background-position-x: 1920px;
  61. }
  62. }
  63. @ keyframes moveRight {
  64. 0% {
  65. background-position-x: 0;
  66. }
  67. 100% {
  68. background-position-x: - 1920px;
  69. }
  70. }
  71. </style>
  72. <body>
  73. <div id=“container”>
  74. <div class=“wave-wrapper”>
  75. <div class=“wave wave1”> </div>
  76. <div class=“wave wave2”> </div>
  77. <div class=“wave wave3”> </div>
  78. </div>
  79. <div class=“content-wrapper”> </div>
  80. </div>
  81. </body>
  82. </html>

图片需要自己准备一张类似下图的均匀的png图片,也可以去下载我的。点击下载 (csdn更新积分制度后好坑啊)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值