I have this demo in code pen I want to add a fade in effect and a fade out effect to the floating boxes, but every-time I add ".webkit-animation: fadein" or fadeout the animation for the element stops working.
e.g.
-webkit-animation: fadein 5s;
I have this demo in code pen I want to add a fade in effect and a fade out effect to the floating boxes, but every-time I add ".webkit-animation: fadein" or fadeout the animation for the element stops working.
e.g.
-webkit-animation: fadein 5s;
I think you need to define your animations simultaneously. You cannot simply define -webkit-animation: fadein 5s;
in one of the nth-child divs because this will override the square animation you set on the li
s themselves.
Additionally, try defining the fadein
and fadeout
animations like you defined the square one:
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeout {
from { opacity: 1; }
to { opacity: 0; }
}
I edited your codepen: http://codepen.io/anon/pen/jbWEQv?editors=110. It has the square
animation working in tandem with the fadein
and fadeout
animations, though you'll need to fix the timing because each square has special timing and I didn't change them all individually.
The main things to look at are the new fadein/out definitions that I made at the bottom of the css, and the code on lines 155 and 156:
-webkit-animation: fadein 12s infinite, square 24s infinite, fadeout 12s 12s infinite;
animation: fadein 12s infinite, square 24s infinite, fadeout 12s 12s infinite;