I am trying to find a CSS-only way to make specific tags (like p
or img
) blink in alternating patterns. While I have been able to find a means to make anything blink (see .blinky
) in code sample, I have not been able to make two separate classes alternate the blinking.
Part of the solution might be the animation-delay
property shown in .blinky2
, but after the specified delay in seconds, it blinks in sync with .blinky
and not offset by the delay.
I found some related SO links that got me started -- Imitating a blink tag with CSS3 animations and CSS Tricks -- but I have not yet seen any instructions to define offset blinking for .blink2
. Is such a thing supported, or does it require further tricks?
.blinky {
animation: blink-animation 1s steps(5, start) infinite;
-webkit-animation: blink-animation 1s steps(5, start) infinite;
font-size: x-large;
color: blue;
display: inline;
}
.blinky2 {
/* Need make this alternate blinking*/
animation: blink-animation 1s steps(5, start) infinite;
-webkit-animation: blink-animation 1s steps(5, start) infinite;
/* This just postpones blinking for 1-sec, then it's in sync with .blinky*/
animation-delay: 1s;
-webkit-animation-delay: 1s;
font-size: x-large;
color: red;
display: inline;
}
@keyframes blink-animation {
to {
visibility: hidden;
}
}
@-webkit-keyframes blink-animation {
to {
visibility: hidden;
}
}
<p>The <var>blinky</var> and <var>blinky2</var> classes should alternate blinking.</p>
<div>
<p class="blinky">Blinky</p>
<p class="blinky2">Blinky 2</p>
<p class="blinky">Blinky</p>
<p class="blinky2">Blinky 2</p>
<p class="blinky">Blinky</p>
</div>