css3 simple animation not working - css

I have an animation with css3
#keyframes aia2{
from{ opacity:1}
to{ opacity:0}
}/* similar with other prefixes */
.animate{
-webkit-animation: aia2 5s linear infinite alternate;
-moz-animation: aia2 5s linear infinite alternate;
-ms-animation: aia2 5s linear infinite alternate;
-o-animation: aia2 5s linear infinite alternate;
animation: aia2 5s linear infinite alternate;
}
html
<ul>
<li class="item" id="term1">1</li>
<li class="item" id="term2">2</li>
<li class="item" id="term3">3</li>
</ul>
I need to animate li but it is not working
$(".item").removeClass("animate");
$(specified id).addClass("animate");
I am adding animate class to the an li and removing for other li tags.
I also tried with setTimeout, no use.
how I can get it?

Instead of adding and removing classes change animation play state. using css3 animation-play-state property
reference
https://developer.mozilla.org/en-US/docs/CSS/animation-play-state

Actually, this works. But only once:
CSS
#keyframes myfirst
{
from {opacity: 0;}
to {opacity: 1;}
}
#-moz-keyframes myfirst /* Firefox */
{
from {opacity: 0;}
to {opacity: 1;}
}
#-webkit-keyframes myfirst /* Safari and Chrome */
{
from {opacity: 0;}
to {opacity: 1;}
}
#-o-keyframes myfirst /* Opera */
{
from {opacity: 0;}
to {opacity: 1;}
}
.animate{
-webkit-animation-name: myfirst;
-webkit-animation-duration: 5s;
-webkit-animation-direction: linear;
-webkit-animation-timing-function: infinite;
}
HTML
<ul>
<li class="item animate" id="term1">1</li>
<li class="item" id="term2">2</li>
<li class="item" id="term3">3</li>
</ul>
Fiddle: http://jsfiddle.net/praveenscience/ACUEg/

and if you use this:
#keyframes aia2{
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 0; }
}
and you could use #-moz-keyframes, #-webkit-keyframes and #-o-keyframes for the different kits
you can find my test here and it's going on forever

Related

Animation does not work in Firefox

#-webkit-keyframes fadein {
from {opacity: 0;}
to {opacity: 1;}
}
#keyframes fadein {
from {opacity: 0;}
to {opacity: 1;}
}
#-moz-keyframes fadein {
from {opacity: 0;}
to {opacity: 1;}
}
.animated-div {
-webkit-animation: fadein 4s 1 forwards;
-moz-animation: fadein 4s 1 forwards;
animation: fadein 4s 1 forwards;
}
<div class="animated-div">hello</div>
Keyframes does not work and item does not fadein on the page, how to be?
I tried different combinations of prefixes, does not help. In Chrome, Opera working fine.
Deleting opacity: 0!important really help,but i dont know how it was animate in Chrome and Opera even with opacity: 0!important. Thanks all.

CSS keyframe animation hiding before start in firefox but not in internet explorer

I have a css keyframe animation, that I want to hide before the animation starts. It is working fine in firefox (40.0.3) but in internet explorer 11 the pictures remain visible until the animation starts.
I followed these tutorials, suggestions
https://graphicfusion.design/blog/design/creating-fancy-css3-fade-in-animations-on-page-load/
and this
Cross-Fade between images with CSS in loop
I have simplified my code, put it all in one sheet, linked in royalty free images and put in three divs to show my confusion.
Am I missing something obvious?
<!-- Internal style sheet -->
<html>
<head>
<style>
/*************************************************/
.Angel03Pink img {
position:absolute;
left:0px;
top:0;
-webkit-animation-name: KEYFRAME_DIRECTIVE_whatItDoes;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 3s;
animation-name: KEYFRAME_DIRECTIVE_whatItDoes;
animation-iteration-count: infinite;
animation-duration: 3s;
max-width:100%;
max-height:100%;
<!--animation-direction: alternate; /* does not seem to like anything that comes after this*/-->
border-style:solid;
border-color: #ff0000 #0000ff;
}
#-webkit-keyframes KEYFRAME_DIRECTIVE_whatItDoes {
from {opacity: 0;}
33% {opacity:0}
66% {opacity: 1;}
99% {opacity: 0;}
to {opacity: 0;}
}
#keyframes KEYFRAME_DIRECTIVE_whatItDoes {
from {opacity: 0;}
33% {opacity:0}
66% {opacity: 1;}
99% {opacity: 0;}
to {opacity: 0;}
}
#f1 {
}
#f2 {
-moz-animation-delay: -1s ; /* Firefox */
-webkit-animation-delay: -1s ; /* Safari and Chrome */
-o-animation-delay: -1s ; /* Opera */
animation-delay: -1s ;
}
#f3 {
-moz-animation-delay: -2s ; /* Firefox */
-webkit-animation-delay: -2s ; /* Safari and Chrome */
-o-animation-delay: -2s ; /* Opera */
animation-delay: -2s ;
}
/*************************************************/
.FloatUP {
animation-delay: 4s;
background-repeat: no-repeat;
height: 500px;
width: 250px;
background-position: 100% 100%;
background-size: 100% 100%;
-webkit-animation-name: FloatUpDirective; /* Chrome, Safari, Opera */
-webkit-animation-duration: 12s; /* Chrome, Safari, Opera */
-webkit-animation-iteration-count: infinite; /* Chrome, Safari, Opera */
animation-name: FloatUpDirective;
animation-duration: 12s;
animation-iteration-count: 1; /*-- can be infinite */
border-style:none;
border-color: orange yellow;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes FloatUpDirective {
0%{-webkit-opacity: 0; -moz-opacity: 0; opacity: 0;}
1% { transform: translateY(300px); }
100% { transform: translateY(0);}
}
/* Standard syntax */
#keyframes FloatUpDirective {
0%{-webkit-opacity: 0; -moz-opacity: 0; opacity: 0;}
1% { transform: translateY(300px); }
100% { transform: translateY(0);}
}
/***********************************/
.common
{
width:100px;
height:100px;
/*background:red;*/
}
/* make keyframes that tell the start state and the end state of our object */
#-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
#-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
#keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.fade-in {
opacity:0; /* make things invisible upon start */
-webkit-animation:fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:1s;
-moz-animation-duration:1s;
animation-duration:1s;
}
.fade-in.CHANGEmeHOWEVERlong {
-webkit-animation-delay: 4s;
-moz-animation-delay: 4s;
animation-delay: 4s;
}
.WithbackGroundImage {
background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg/90px-%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg');
background-repeat: no-repeat;
background-size: 100% 100%;
border-style:none; <-- can be border-style:solid-->
}
/**********************************/
</style>
</head>
<body>
<div class="fade-in CHANGEmeHOWEVERlong ">
<div class="common FloatUP" id="four" style="
position:absolute;left:0px;top:0px;">
<div class="Angel03Pink" >
<img id="f1" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Schutzengel_Dorigo.jpg/84px-Schutzengel_Dorigo.jpg">
<img id="f2" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg/90px-%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg">
<img id="f3" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg/90px-%C5%81u%C5%BCna_cemetery_-_Guardian_angel.jpg">
</div>
four comes in after 4 seconds</div>
</div>
<div class="fade-in CHANGEmeHOWEVERlong">
<div class="common WithbackGroundImage FloatUP" id="four" style="
position:absolute;left:150px;top:0px;">four comes in after 4 seconds</div>
</div>
<div class="fade-in CHANGEmeHOWEVERlong">
<div class="common WithbackGroundImage" id="four" style="
position:absolute;left:300px;top:0px;">four comes in after 4 seconds</div></div>
<div class="common WithbackGroundImage" id="two" style="position:absolute;left:450px;top:0px;")>Div With backGroundImage</div><br>
</body>
</html>
Thanks
I I just had to swap the div around so that they read
{ I just had to swap the div around so that they read
I did a js fiddle on this at [1]http://jsfiddle.net/melvinT/81y3vy9m/

visibility: hidden working differently on different browsers

I have a question that might sound stupid, but here it goes anyways.
For starters, here is the website I'm creating.
www.redshedproductionsllc.com
I have an animation running on an h1 element on my website that fades in after a delay. The problem was is that the text showed before the animation started, so it kind of had a glitchy start. I found a workaround that works flawlessly on chrome, but not on any other browser. The element simply stays hidden. Here is my CSS.
#fading1 {
animation: fadein 4s;
-moz-animation: fadein 4s; /* Firefox */
-webkit-animation: fadein 4s; /* Safari and Chrome */
-o-animation: fadein 4s; /* Opera */
}
#fading2 {
visibility: hidden;
animation: fadein 4s;
-moz-animation: fadein 4s; /* Firefox */
-webkit-animation: fadein 4s; /* Safari and Chrome */
-o-animation: fadein -4s; /* Opera */
-moz-animation-delay: 2s;
-webkit-animation-delay: 2s;
-ms-animation-delay: 2s;
-o-animation-delay: 2s;
animation-delay: 2s;
-moz-animation-fill-mode: forwards; /*FF 5+*/
-webkit-animation-fill-mode: forwards; /*Chrome 16+, Safari 4+*/
-o-animation-fill-mode: forwards; /*Not implemented yet*/
-ms-animation-fill-mode: forwards; /*IE 10+*/
animation-fill-mode: forwards; /*when the spec is finished*/
}
Check it out on chrome, then check it out on firefox or safari. Chrome fades in flawlessly, while the other two stay hidden. Please help!!!
First of all, there is no such thing as moz-prefixed animation-delay. Having -moz-animation-delay: 2s is unneccessary. I'm not sure why it is working in chrome and not Firefox, but I have a feeling that the animation of visibility doesn't work well in all browsers.
It would make more sense to me to fade it in from opacity: 0 to opacity: 1 over three seconds, but make the first two seconds the delay, keeping the opacity at 0.
#keyframes fadein {
0% {opacity: 0;}
66% {opacity: 0;}
100% {opacity: 1;}
}
#-webkit-keyframes fadein {
0% {opacity: 0;}
66% {opacity: 0;}
100% {opacity: 1;}
}
.fade{
opacity: 1;
-moz-animation: fadein 3s;
animation: fadein 3s;
width: 100px;
height: 100px;
background: blue;
}
JSFiddle
I am not very sure but you have to use something like this:
So the thing is, you have to specify certain functions of CSS for each and every browser, so you should do like this:
#-webkit-keyframes fadein {
0% {opacity: 0;}
66% {opacity: 0;}
100% {opacity: 1;}
-moz-boxshadow
Read MDN guides for these prefixes.
Hope it helps! :)

CSS3 animation fadeOut

I'm trying to dissappear Bootstrap Alert after 3seconds. I made it, but it just dissapears and keeps the height of div. Can I remove that div with CSS only? I tried display:none; and it also didn't work. I need help.
This is what I did:
CSS:
.alert-success {
-webkit-animation: fadeOut 3s linear forwards;
animation: fadeOut 3s linear forwards;
}
#-webkit-keyframes fadeOut {
0% {opacity: 1;}
70% {opacity: 1;}
90% {opacity: 1;-webkit-transform: translateY(0px);}
100% {opacity: 0;-webkit-transform: translateY(-30px);}
}
HTML:
<div class="alert alert-success">
Well done! You successfully read this important alert message.
</div>
Thanks in advance
Give this a try!
JSFiddle:
http://jsfiddle.net/Q9kYa/9/
#alert-success{
background-color: #FF0000;
animation:alert-success 0.5s 1;
-webkit-animation:alert-success 0.5s 1;
animation-fill-mode: forwards;
animation-delay:2s;
-webkit-animation-delay:1s; /* Safari and Chrome */
-webkit-animation-fill-mode: forwards;
}
#-webkit-keyframes alert-success{
0% {opacity: 1;}
70% {opacity: 1;}
90% {opacity: 1;-webkit-transform: translateY(0px);}
100% {opacity: 0;-webkit-transform: translateY(-30px);}
}

Adding an opacity change and a transform in CSS

How do I combine these two animations (translate & buttonFade) so that they both affect the same image ? Both animations work seperatley but not together. Is there a way to combine the two? (I have omitted the -moz- , -o- etc purposefully to make it easier to read, I have tried adding these and it makes no difference)
translate {
-webkit-animation: moveLeft 1s forwards;
}
#-webkit-keyframes moveLeft {
0% {-webkit-transform: translateX(0px)}
100% {-webkit-transform: translateX(100px)}
}
.intro-button{
position:absolute;
top: 350px;
left: 625px;
opacity: 0;
-webkit-animation: buttonFade 3s 1 forwards;
-webkit-animation-delay: 2s;
}
#-webkit-keyframes buttonFade {
0% {opacity: 0;}
80% {opacity: 0;}
100% {opacity: 1;}
}
Any help would be much appreciated!
You can list multiple animations by separating them with a comma, as such you can simply call moveLeft from your CSS for .intro-button and remove your CSS for translate (which by the way is not a valid selector).
You'll also want to add a other value for the animation delay, which should be first animation delay + first animation duration (4s)
Demo Fiddle
Change your CSS thusly:
#-webkit-keyframes moveLeft {
0% {
-webkit-transform: translateX(0px)
}
100% {
-webkit-transform: translateX(100px)
}
}
.intro-button {
position:absolute;
top: 350px;
left: 625px;
opacity: 0;
-webkit-animation: buttonFade 3s 1 forwards, moveLeft 1s forwards;
-webkit-animation-delay: 2s, 4s;
}
#-webkit-keyframes buttonFade {
0% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 1;
}
}
You can actually concatenate the animation property further:
-webkit-animation: buttonFade 3s 2s 1 forwards, moveLeft 1s 4s forwards;
Removing the need to set animation duration separately The shorthand foranimation is:
animation: animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode;

Resources