How to create a pulsing glow ring animation in CSS?
Asked Answered
B

1

11

I like the way this website made their rings glow and pulse out and would like to know how they did it.

I can make something similar but I'm not very good.

So this is all I was able to figure out but it doesn't seem to work.

CSS:

glowycircleouter.blue .glow4 {
  box-shadow: 0 0 25px #287ec6;
}
.glowycircleouter .glow4 {
  -webkit-animation: glowyglow 3s 2250ms infinite;
  -moz-animation: glowyglow 3s 2250ms infinite;
  -ms-animation: glowyglow 3s 2250ms infinite;
  -o-animation: glowyglow 3s 2250ms infinite;
  animation: glowyglow 3s 2250ms infinite;
  animation-name: glowyglow;
  animation-duration: 3s;
  animation-timing-function: initial;
  animation-delay: 2250ms;
  animation-iteration-count: infinite;
  animation-direction: initial;
  animation-fill-mode: initial;
  animation-play-state: initial;
}
.glowycircleouter .glow4 {
  opacity: 0;
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 200%;
  height: 200%;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  -o-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
}

HTML:

<span class="glow4"></span>
Belaud answered 19/4, 2016 at 1:54 Comment(4)
From looking at their source code, it looks like they used keyframes, border-radius: 50%, opacity, transform, translate, and scale.Phantasmal
Googling 'css pulsating rings' returns a stack of codepens and things: jsfiddle.net/dirtyharry/dw51cgu6Ondrea
maybe helpful: https://mcmap.net/q/1017936/-pulsating-ring-animation-with-cssComedian
Are you looking for something like that thecodeplayer.com/walkthrough/leaky-coffee-mugTorbert
S
32

The threads linked in comments are helpful but I don't think this is an exact duplicate because this one is slightly more complex due to the need for multiple rings.

We can create this effect by animating transform: scale() and opacity of the elements. Here, we need more than 1 element because in the linked website we can see atleast 3 rings at any given point of time (one which is fading-in, one which is at its peak, one which is fading-out). By adding the same animation to two pseudo-elements, an inner element (the span) and by delaying the animation on two of them we can achieve the required animation effect.

div {
  position: relative;
  height: 100px;
  width: 100px;
  border-radius: 50%;
  margin: 50px;
  border: 2px solid white;
}
div:before,
div:after, span {
  position: absolute;
  content: '';
  height: 100%;
  width: 100%;
  top: 0%;
  left: 0%;
  border-radius: 50%;
  box-shadow: 0 0 15px #287ec6;
  animation: glow-grow 2s ease-out infinite;
}
div:after {
  animation-delay: .66s;
}
span{
  animation-delay: 1.33s;
  }
@keyframes glow-grow {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
body {
  background: black;
}
<div>
  <span></span>
</div>
Skintight answered 19/4, 2016 at 7:5 Comment(1)
Hi, if using not infinite animation animation: 6s ease-out 0s 1 glow-grow;, how possible to remove stucked wawes after the end of animation?Cloraclorinda

© 2022 - 2024 — McMap. All rights reserved.