javascript - 如何使用 HTML 5 创建发光效果

标签 javascript css html css-animations

寻求帮助来实现 Stacks 新文档网站上看到的那个小蓝点,它非常适合为我正在构建的显示服务运行状况/指标的仪表板制作动画。我使用 Chrome 的检查器抓取了 html/css,但我在这方面很糟糕,我什至无法得到一个点,更不用说发光的蓝色点了;-D

https://jsfiddle.net/raffinyc/3trup2c1/

.help-bubble:after {
  content: "";
  background-color: #3af;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: absolute;
  display: block;
  top: 1px;
  left: 1px;
}
<span class="help-bubble-outer-dot">
        <span class="help-bubble-inner-dot"></span>
</span>

enter image description here

最佳答案

Here's the full reproduction .动画充分利用了伪元素。 CSS:

.help-bubble .help-bubble-outer-dot {
    margin: 1px;
    display: block;
    text-align: center;
    opacity: 1;
    background-color: rgba(0,149,255,0.4);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: help-bubble-pulse 1.5s linear infinite;
}

.help-bubble {
  display: block;
  position: absolute;
  z-index: 2;
  cursor: pointer;
  left: 40px;
  top: 40px;
}

.help-bubble::after {
    content: "";
    background-color: #3af;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    display: block;
    top: 1px;
    left: 1px;
}

.help-bubble .help-bubble-inner-dot {
    background-position: absolute;
    display: block;
    text-align: center;
    opacity: 1;
    background-color: rgba(0,149,255,0.4);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    -webkit-animation: help-bubble-pulse 1.5s linear infinite;
    -moz-animation: help-bubble-pulse 1.5s linear infinite;
    -o-animation: help-bubble-pulse 1.5s linear infinite;
    animation: help-bubble-pulse 1.5s linear infinite;
}

.help-bubble .help-bubble-inner-dot:after {
    content: "";
    background-position: absolute;
    display: block;
    text-align: center;
    opacity: 1;
    background-color: rgba(0,149,255,0.4);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    -webkit-animation: help-bubble-pulse 1.5s linear infinite;
    -moz-animation: help-bubble-pulse 1.5s linear infinite;
    -o-animation: help-bubble-pulse 1.5s linear infinite;
    animation: help-bubble-pulse 1.5s linear infinite;
}

@keyframes help-bubble-pulse{
  0% {
    transform: scale(1);
    opacity: .75;
  }
  25% {
    transform:scale(1);
    opacity:.75;
  }
  100% {
    transform:scale(2.5);
    opacity:0
  }
}

郑重声明,我不太精通代码知识产权,但如果不以某种方式将其变成您自己的,您不太可能有权使用它。

关于javascript - 如何使用 HTML 5 创建发光效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38537415/

相关文章:

javascript - 即使我检查了另一个单选按钮,单选按钮仍保持选中状态?

html - css flexbox,带有约束的可变高度顶部和底部

javascript - 从 Django View 打开新选项卡的命令

javascript - 在 Ember.js 中用树形结构组织 MVC

javascript - ipad上的背景音乐不会停止

php - codeigniter 日历可以用两种不同的颜色设置样式吗?

javascript - 使用 jQuery CSS 的图像缩放功能

jquery - 使用 jQuery 删除 Bootstrap 缩略图

javascript - 我应该使用 jQuery 的 getScript() 还是大量的 &lt;script&gt; 标签?

javascript - 基于单选按钮的结账表单计算 - Laravel 5.2