- This topic is empty.
-
AuthorPosts
-
May 3, 2018 at 7:37 am #270552AlkadixParticipant
Hello,
I am trying to do a css3 animation on my website, basically it’s for a text banner, with text appearing from right to left, and disappearing from right to left for 15 secs.
So my css animation code look like this :
animation: animationFrames ease 15s; animation-iteration-count: infinite; animation-fill-mode:forwards; animation-delay: 8s;
My keyframes looks like that :
0%, 4% { transform: translate(1200px,0px) ; } 4%, 6% { transform: translate(-370px,0px) ; } 6%, 8% { transform: translate(-330px,0px) ; } 8%, 98%{ transform: translate(-330px,0px) ; } 98%, 100%{ transform: translate(-660px,0px) ; }
So I want it to freeze and do nothing while on the line : 8%, 98%{transform: translate(-330px,0px) ;}
and then quickly throw the element out to the left with that line : 98%, 100%{transform: translate(-660px,0px) ;}The problem is it seems to do that :
8%, 100%{ transform: translate(-660px,0px) ; }
Basically it just scrolls my element slowly to the left with no pauses, instead of pausing for pretty much all the time, and then throw it away to the left.
Am I doing something wrong ? How can I do that ?
Thanks
May 3, 2018 at 9:08 am #270558BeverleyhParticipantCan you demo it for us in CodePen? It gives us something contextual to play with for live edits.
May 4, 2018 at 12:14 am #270629AlkadixParticipantA simple example here : https://codepen.io/anon/pen/VxzbGM
May 4, 2018 at 1:20 am #270630PoganyParticipantHi
You may use 2 animations instead of one.
I’ve made a fork of your pen: https://codepen.io/giaco/pen/gzxxMP?editors=0100What I’ve changed:
I’ve added the Prefixfree library so I can write the code without prefixes.
I’ve broke your animation in 2 animations.
You may want to change the timing.I hope this helps.
May 4, 2018 at 2:29 am #270634AlkadixParticipantThanks for your answer !
The thing is I also wanted to repeat the animation infinitely, but with 2 animations on one element and “animation-iteration-count:infinite;”, animations don’t seem to queue and just repeat animation1 and animation2 infinitely without taking either one into account, is it the best option I have to use 2 animations and should I continue to mess with timings to finally have a consistent and flowing animation ?
May 4, 2018 at 2:30 am #270635BeverleyhParticipantYour start and stop points are overlapping. Just knock the % increment over a tad on your keyframes so that the numbers don’t repeat and things should behave more like you’d expect…
@keyframes animationFrames { 0%, 4% { transform:translate(1200px,0) } 5%, 6% { transform:translate(-370px,0) } 7%, 8% { transform:translate(-320px,0) } 9%, 98% { transform:translate(-320px,0) } 99%, 100% { transform:translate(-660px,0) } }
May 4, 2018 at 2:34 am #270637AlkadixParticipantOooow that makes sense, that’s right I didn’t try like that.
Thanks you
May 7, 2018 at 9:07 pm #270784MamunParticipantYou can try changing your keyframes like this:
@keyframes animationFrames{
0%, 4% {
transform: translate(1200px,0px) ;
}
4%, 6% {
transform: translate(-370px,0px) ;
}
6%, 98% {
transform: translate(-320px,0px) ;
}
100%{
transform: translate(-660px,0px) ;
}
} -
AuthorPosts
- The forum ‘Design’ is closed to new topics and replies.