Currently, I have this code:
@-webkit-keyframes blinker {
from { opacity: 1.0; }
to { opacity: 0.0; }
}
.waitingForConnection {
-webkit-animation-name: blinker;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier(.5, 0, 1, 1);
-webkit-animation-duration: 1.7s;
}
It blinks, but it only blinks in "one direction". I mean, it only fades out, and then it appears back with opacity: 1.0
, then again fades out, appears again, and so on... I would like it to fade out, and then "raise" from this fade back again to opacity: 1.0
. Is that possible?
Change duration and opacity to suit.
You are first setting
opacity: 1;
and then you are ending it on0
, so it starts from0%
and ends on100%
so instead just set opacity to0
at50%
and rest will take care of itself.Demo
Here, am setting animation duration should be
1 second
, than am setting thetiming
tolinear
that means it will be constant throughout, and last am usinginfinite
that means it will go on and on.As commented, this won't work on older versions of Internet Explorer, for that, you need to use jQuery or JavaScript....
Thanks to Alnitak for suggesting a better approach.
Demo (Blinker using jQuery)
I don't know why but animating only the
visibility
property is not working on any browser.What you can do is animate the
opacity
property in such a way that the browser doesn't have enough frames to fade in or out the text.Example:
The best way to get a pure "100% on, 100% off" blink, like the old
<blink>
is like this:Use the
alternate
value foranimation-direction
(and you don't need to add any keframes this way).CSS:
I've removed the
from
keyframe. If it's missing, it gets generated from the value you've set for the animated property (opacity
in this case) on the element, or if you haven't set it (and you haven't in this case), from the default value (which is1
foropacity
).And please don't use just the WebKit version. Add the unprefixed one after it as well. If you just want to write less code, use the shorthand.