【问题标题】:How to create a pulsing glow ring animation in CSS?如何在 CSS 中创建脉冲发光环动画?
【发布时间】:2019-08-27 21:36:37
【问题描述】:

我喜欢这个website 让他们的戒指发光和跳动的方式,我想知道他们是怎么做到的。

我可以做类似的东西,但我不是很好。

所以这就是我能够弄清楚但它似乎不起作用。

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>

【问题讨论】:

标签: css css-animations visual-web-developer


【解决方案1】:

在 cmets 中链接的线程很有帮助,但我不认为这是完全重复的,因为由于需要多个环,这个线程稍微复杂一些。

我们可以通过动画元素的transform: scale()opacity 来创建这种效果。在这里,我们需要超过 1 个元素,因为在链接的网站中,我们可以在任何给定时间点看到至少 3 个环(一个淡入,一个处于峰值,一个淡出)。通过将相同的动画添加到两个伪元素,一个内部元素(span),并通过延迟其中两个的动画,我们可以实现所需的动画效果。

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>

【讨论】:

  • 你好,如果使用非无限动画animation: 6s ease-out 0s 1 glow-grow;,动画结束后如何去除卡住的wawes?
猜你喜欢
  • 1970-01-01
  • 2021-02-24
  • 2015-09-02
  • 1970-01-01
  • 2012-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-02
相关资源
最近更新 更多