How to create a pulsing glow ring animation in CSS?

喜欢而已 提交于 2019-11-30 13:45:10

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!