【问题标题】:Shine effect automatically with css使用css自动发光效果
【发布时间】:2016-03-09 18:07:58
【问题描述】:

我正在尝试每 5 秒自动运行一次发光效果(没有悬停)。

http://jsfiddle.net/AntonTrollback/nqQc7/

.icon:after {
  content: "";
  position: absolute;
  top: -110%;
  left: -210%;
  width: 200%;
  height: 200%;
  opacity: 0;
  transform: rotate(30deg);
  background: rgba(255, 255, 255, 0.13);
  background: linear-gradient(
    to right, 
    rgba(255, 255, 255, 0.13) 0%,
    rgba(255, 255, 255, 0.13) 77%,
    rgba(255, 255, 255, 0.5) 92%,
    rgba(255, 255, 255, 0.0) 100%
  );
}

.icon:hover:after {
  opacity: 1;
  top: -30%;
  left: -30%;
  transition-property: left, top, opacity;
  transition-duration: 0.7s, 0.7s, 0.15s;
  transition-timing-function: ease;
}

【问题讨论】:

  • 你能说明发生了什么问题吗?很多人可能不愿意点击链接,这大概说明了问题所在,因为它可以去任何地方。
  • 我正在尝试让闪耀效果每 X 秒自动工作一次,但现在这个效果只适用于 :hover。 @GrahamAsher
  • 使用动画代替过渡。

标签: jquery html css animation effects


【解决方案1】:

你可以像这样创建 CSS 动画DEMO

 @keyframes shine{
  10% {
    opacity: 1;
    top: -30%;
    left: -30%;
    transition-property: left, top, opacity;
    transition-duration: 0.7s, 0.7s, 0.15s;
    transition-timing-function: ease;
  }
  100% {
    opacity: 0;
    top: -30%;
    left: -30%;
    transition-property: left, top, opacity;
  }
}

【讨论】:

  • @Anderson 你确定吗,我刚刚知道你希望它每 5 秒运行一次,但事实并非如此。我很快就会弄清楚的。
  • 您知道如何禁用该转换吗?
  • 是的。我相信这对我有帮助。
  • 好吧,我想我明白了。这个像你想要的那样每 5 秒发光一次 jsfiddle.net/nqQc7/512
  • 是的。实际上,它甚至更好。
猜你喜欢
  • 1970-01-01
  • 2018-05-31
  • 1970-01-01
  • 2017-07-29
  • 1970-01-01
  • 2010-12-27
  • 2016-07-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多