I am trying to recreate the effect of a rowan of material in pure CSS, and I have a prepared animation. The problem is that I cannot get the animation to work fully when the element is clicked. I tried with transitions ( try 1 demo , try 2 demos ), but not one of them will run all the way.
Another more likely method is with CSS3 animations (I'm not worried about browser support right now). I have animation keyframes, but Iβve never worked with animation before, and I donβt see a way to start the animation when clicked.
@-webkit-keyframes ripple { 0% { background-size: 1% 1%; opacity: 0.5; } 70% { background-size: 1000% 1000%; opacity: 0.2; } 100% { opacity: 0; background-size: 1000% 1000%; } } @keyframes ripple { 0% { background-size: 1% 1%; opacity: 0.5; } 70% { background-size: 1000% 1000%; opacity: 0.2; } 100% { opacity: 0; background-size: 1000% 1000%; } } .button { background-color: blue; padding: 12px; display: inline-block; border-radius: 5px; color: white; font-family: sans-serif; text-transform: uppercase; position: relative; overflow: hidden; } .button::after { position: absolute; content: " "; height: 100%; width: 100%; top: 0; left: 0; pointer-events: none; background-image: radial-gradient(circle at center, #FFF 0%, #FFF 10%, transparent 10.1%, transparent 100%); background-position: center center; background-repeat: no-repeat; background-color: transparent; -webkit-animation: ripple 0.6s 0s normal forwards infinite running ease-in; animation: ripple 0.6s 0s normal forwards infinite running ease-in; } .button:active::after { }
<div class="ripple button"><a>Click this</a></div>
Doubts that I was thinking about but could not do the job include changing the animation delay, transparency ::after using opacity and using the animation synchronization function.
source share