CSS3 keyframe animation including delay, toggled with JS -
i'm trying animate (fade-in) 3 buttons. html:
<aside> <p><a href="#"><i class="icon-facebook"></i> share</a></p> <p><a href="#"><i class="icon-twitter"></i> tweet</a></p> <p><a href="#"><i class="icon-envelope"></i> mail</a></p> </aside> and css (the class .aside-check gets applied javascript)
.aside-check { animation: fadein 2s; } @keyframes fadein { {opacity:0;} {opacity:1;} } what now, give every paragraph little delay, tried
p:nth-child(1) {animation-delay:2s} p:nth-child(2) {animation-delay:3s} p:nth-child(3) {animation-delay:4s} but doesn't work. unfortunately don't know did wrong...:/
well, first need apply animation paragraphs not aside. remember, animations don't inherit. second, don't forget webkit prefixes! it's pain webkit browsers still require -webkit- before animation properties , keyframe definitions. without animation won't work on, chrome, safari, android, etc. (if can't remember if need prefixes take @ caniuse.com http://caniuse.com/#feat=css-animation)
also note if want paragraphs hidden revealed want define them opacity of 0 , set 'animation-fill-mode' forwards properties in 'to' frame stick after animation finishes.
i made little js fiddle working example, hope helps!
http://jsfiddle.net/ashwell/hqbzu/
here important bits: animations applied paragraphs fill-mode set , starting opacity.
.aside-check > p{ animation: fadein 2s; -webkit-animation: fadein 2s; animation-fill-mode: forwards; -webkit-animation-fill-mode: forwards; opacity: 0; } you'll need webkit key frames
@-webkit-keyframes fadein { { opacity: 0; } { opacity: 1; } } and don't forget add -webkit-animation-delay: 2s; each of nth-child selectors respected delay time!
i hope answer isn't coming late!
Comments
Post a Comment