【问题标题】:How to create glowing effect with HTML 5如何使用 HTML 5 创建发光效果
【发布时间】:2017-09-16 23:37:23
【问题描述】:

寻求帮助来实现 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>

【问题讨论】:

标签: javascript css html css-animations


【解决方案1】:

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
  }
}

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

【讨论】:

  • 关于钱,非常好,并且记录在案,无意按原样使用此代码;只是想看看它是如何实现的,代码示例消除了所有噪音,让我更容易学习这项技术,这确实是我的目标。
  • @ZiedRebhi `.help-bubble { 显示:内联块; z指数:2;光标:指针;位置:相对; }`
【解决方案2】:

试试box-shadow

-webkit-box-shadow: 0px 0px 20px 0px rgba(0,225,255,1);
-moz-box-shadow: 0px 0px 20px 0px rgba(0,225,255,1);
box-shadow: 0px 0px 20px 0px rgba(0,225,255,1);

语法是:

0px (horizontal offset) 0px (vertical offset) 20px (bur value) 0px (spread value) rgba (color value)

查看这里了解更多信息:

https://css-tricks.com/snippets/css/css-box-shadow/

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多