I have an animation set on :before
that works fine on Chrome but it doesn't work on Safari (IOS9 iPhone or 9 - El Capitan) neither on Firefox.
.hey {
color: white;
}
.hey:before {
content: 'Hey \a there';
white-space: pre;
position: absolute;
color: red;
-moz-animation: heyThere 2250ms steps(11); /* for firefox */
-webkit-animation: heyThere 2250ms steps(11); /* for safari, chrome & opera */
}
@keyframes heyThere {
0% {content: "";}
1% {content: "";}
75% {content: "";}
77% {content: "H";}
80% {content: "He";}
83% {content: "Hey";}
85% {content: "Hey ";}
87% {content: "Hey \a t";}
90% {content: "Hey \a th";}
93% {content: "Hey \a the";}
95% {content: "Hey \a ther";}
97% {content: "Hey \a there";}
100% {content: "Hey \a there";}
}
@-moz-keyframes heyThere { /* animation for firefox */
0% {content: "";}
1% {content: "";}
75% {content: "";}
77% {content: "H";}
80% {content: "He";}
83% {content: "Hey";}
85% {content: "Hey ";}
87% {content: "Hey \a t";}
90% {content: "Hey \a th";}
93% {content: "Hey \a the";}
95% {content: "Hey \a ther";}
97% {content: "Hey \a there";}
100% {content: "Hey \a there";}
}
@-webkit-keyframes heyThere { /* animation for chrome, safari & opera */
0% {content: "";}
1% {content: "";}
75% {content: "";}
77% {content: "H";}
80% {content: "He";}
83% {content: "Hey";}
85% {content: "Hey ";}
87% {content: "Hey \a t";}
90% {content: "Hey \a th";}
93% {content: "Hey \a the";}
95% {content: "Hey \a ther";}
97% {content: "Hey \a there";}
100% {content: "Hey \a there";}
}
<div class="hey">Hey there</div>
As mentioned by @Pavan Kumar Jorrigala it is not possible to animate the
content
property of a pseudo element except in Chrome on desktop.Here is an ass-backwards approach to what you are trying to achieve:
jsfiddle
Try adding a display property to the :before. For example, add display:block; and see if that affects the animation.
I also gone through the entire web I didn't found any thing, according to the following reference we can only achieve with JavaScript.
Reference
@asimovwasright answer is right.
To avoid so much repetition on css, I used a
@for
with SCSS to loop through all available spans (in this case 8)And the HTML:
in safari and firefox the code isn't animation, instead you'll have to write -moz-animation and also -webkit-animation, like this code:
`