【问题标题】:Divs that flash in order按顺序闪烁的 div
【发布时间】:2015-03-26 04:24:37
【问题描述】:

我正在尝试使 DIV 一个接一个地以一种颜色闪烁,只使用 HTML 和 CSS。我已经到了他们正在闪烁的地步,但我无法让他们以我想要的方式做到这一点。我在考虑骑士骑士汽车的红灯。任何帮助都会很好。

编辑:谢谢,我在发布后几分钟就知道了

我的代码:

HTML

<div id="d1" class="div"></div>
<div id="d2" class="div"></div>
<div id="d3" class="div"></div>
<div id="d4" class="div"></div>
<div id="d5" class="div"></div>
<div id="d6" class="div"></div>
<div id="d7" class="div"></div>
<div id="d8" class="div"></div>

CSS

@charset "utf-8";
/* CSS Document */

@-webkit-keyframes smooth {
    0% { background: #000000;}
    70% { background: #000000;}
    71% { background: #ff0000;}
    83% { background: #f00000;}
    86% { background: #e00000;}
    89% { background: #a00000;}
    92% { background: #900000;}
    95% { background: #600000;}
    97% { background: #400000;}
    99% { background: #200000;}
    100% { background: #000000;}
}
@-o-keyframes smooth {
    0% { background: #000000;}
    70% { background: #000000;}
    71% { background: #ff0000;}
    83% { background: #f00000;}
    86% { background: #e00000;}
    89% { background: #a00000;}
    92% { background: #900000;}
    95% { background: #600000;}
    97% { background: #400000;}
    99% { background: #200000;}
    100% { background: #000000;}
}
@-moz-keyframes smooth
{
    0% { background: #000000;}
    70% { background: #000000;}
    71% { background: #ff0000;}
    83% { background: #f00000;}
    86% { background: #e00000;}
    89% { background: #a00000;}
    92% { background: #900000;}
    95% { background: #600000;}
    97% { background: #400000;}
    99% { background: #200000;}
    100% { background: #000000;}
}
@keyframes smooth {
    0% { background: #000000;}
    70% { background: #000000;}
    71% { background: #ff0000;}
    83% { background: #f00000;}
    86% { background: #e00000;}
    89% { background: #a00000;}
    92% { background: #900000;}
    95% { background: #600000;}
    97% { background: #400000;}
    99% { background: #200000;}
    100% { background: #000000;}
}

body
{
    background:dark-grey;
    height:100%;
}

#d1
{
    animation-delay:0s;
    -moz-animation-delay:0s;
    -o-animation-delay:0s;
    -webkit-animation-delay:0s; 
}

#d2
{
    animation-delay:0.2s;
    -moz-animation-delay:0.2s;
    -o-animation-delay:0.2s;
    -webkit-animation-delay:0.2s;

}

#d3
{
    animation-delay:0.4s;
    -moz-animation-delay:0.4s;
    -o-animation-delay:0.4s;
    -webkit-animation-delay:0.4s;

}

#d4
{
    animation-delay:0.6s;
    -moz-animation-delay:0.6s;
    -o-animation-delay:0.6s;
    -webkit-animation-delay:0.6s;

}

#d5
{
    animation-delay:0.8s;
    -moz-animation-delay:0.8s;
    -o-animation-delay:0.8s;
    -webkit-animation-delay:0.8s;

}



.div
{
    animation:ease-in smooth 1s infinite;
    -moz-animation:ease-in smooth 1s infinite;
    -o-animation:ease-in smooth 1s infinite;
    -webkit-animation:ease-in smooth 1s infinite;

    width:11.5%;
    height:10vh;

    background:black;

    display:inline-block;
}

【问题讨论】:

  • 请在此处尝试添加您的代码...否则它是题外话,它将被关闭。
  • 我在发帖几分钟后就知道了你已经知道答案了吗?
  • 是的,我找到了答案
  • 那么请把它标记为版主注意请求删除
  • 无论出于何种原因我不能,它不会在文本区域中输入...

标签: html css css-animations


【解决方案1】:

使用延迟,这里有一篇关于关键帧动画的好帖子。

http://css-tricks.com/snippets/css/keyframe-animation-syntax/

【讨论】:

  • 我现在看到你终于添加了你的代码,你已经有延迟了。忽略我上面的评论。
  • 不是我!但是您应该发布链接描述内容的摘要,以防万一链接将来出现故障。
  • 顺便说一句,我没有投反对票,但是谢谢,我猜你回答的时候才知道。
猜你喜欢
  • 2018-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多