0

I have an oval, and inside the oval, I have a strip that I need it to have waves

I have made this:

.strip {
  content: "";
  position: relative;
  background: #4286f4;
  z-index: 1;
  width: 100%;
  height: 100%;
  bottom: 0%;
  animation: wipe 8s cubic-bezier(0.9, 0.7, 0.8, 0.8) forwards;
  animation-iteration-count: infinite;
}

@keyframes wipe {
  from {
    bottom: 0%;
  }
  to {
    bottom: 100%;
  }
}

.oval {
  position: absolute;
  background: #343434;
  -moz-border-radius: 0 50% / 0 100%;
  -webkit-border-radius: 0 50% / 0 100%;
  border-radius: 150px;
  height: 100px;
  width: 80%;
  overflow: hidden;
}
<div class="oval">
  <div class="strip"></div>
</div>

How can i make that my strip have infinite wave animation?

Ivan
  • 34,531
  • 8
  • 55
  • 100
Isaías Orozco Toledo
  • 1,919
  • 5
  • 19
  • 35
  • Do you mean that the blue strip will slide into view from the bottom and out of view at the top, in an infinite loop? – showdev May 15 '18 at 22:40
  • Several different ideas! I guess we're not clear on what you're aiming for ¯\\_(ツ)_/¯ – showdev May 15 '18 at 22:49
  • @showdev yes lol :p I went to the funniest idea I guess :p – Temani Afif May 15 '18 at 22:49
  • @TemaniAfif I like it! Actual wave shapes. I didn't consider that. – showdev May 15 '18 at 22:50
  • Haha, ok i don´t know why the the blue strip runs like that, in my solution, the strip runs from bottom to top. Ok, the animation that i look is the waves effect in my strip – Isaías Orozco Toledo May 15 '18 at 22:52
  • 1
    Sorry, I'm still not sure what you mean by "waves effect". – showdev May 15 '18 at 22:55
  • @showdev Animation like water waves – Isaías Orozco Toledo May 15 '18 at 22:57
  • Ah, ok. There are many different ways that can look; you might want to narrow it down. Here's [one example](https://codepen.io/tedmcdo/pen/PqxKXg). Here's [another](https://codepen.io/loktar00/pen/kfrKC). You might find this useful: [Animated text with CSS wave](https://stackoverflow.com/questions/41426043/animated-text-with-css-wave) – showdev May 15 '18 at 23:00
  • Possible duplicate of [Filling water animation](https://stackoverflow.com/questions/29738787/filling-water-animation). – showdev May 15 '18 at 23:16

2 Answers2

1

You can try some repeated radial-gradient over a linear-graident to create the waves. Then you can simply animate the background-position and you can get rid of one DOM element.

@keyframes wipe {
  from {
    background-position:0 85px,0 120px;
  }
  to {
    background-position:100px -45px,100px -20px;
  }
}

.oval {
  border-radius: 150px;
  height: 100px;
  width: 80%;
  overflow: hidden;
  background:
   radial-gradient(circle at center,#4286f4 67%,transparent 67.5%)0 5px /50px 50px repeat-x,
   linear-gradient(#343434,#343434)0 30px/100% 150% repeat-x;
  background-color: #4286f4;
  animation: wipe 8s cubic-bezier(0.9, 0.7, 0.8, 0.8) forwards;
  animation-iteration-count: infinite;
}
<div class="oval">
  
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
0

If I understand correctly you want the wave to go up and down?

You can specify percentages instead of from and to as keyframes-selector

.strip {
  content: "";
  position: relative;
  background: #4286f4;
  z-index: 1;
  width: 100%;
  height: 100%;
  bottom: 0%;
  animation: wipe 8s cubic-bezier(0.9, 0.7, 0.8, 0.8) forwards;
  animation-iteration-count: infinite;
}

@keyframes wipe {
  0% {
    bottom: 0%;
  }
  50% {
    bottom: 100%;
  }
  100% {
    bottom: 0%;
  }
}

.oval {
  position: absolute;
  background: #343434;
  -moz-border-radius: 0 50% / 0 100%;
  -webkit-border-radius: 0 50% / 0 100%;
  border-radius: 150px;
  height: 100px;
  width: 80%;
  overflow: hidden;
}
<div class="oval">
  <div class="strip"></div>
</div>
Ivan
  • 34,531
  • 8
  • 55
  • 100