Your issue stems from applying two animations at once that you actually want to run in sequence. To get this working reliably you have two options:
CSS only: http://jsfiddle.net/marionebl/M9LR6/
Note opacity: 0; to keep the message hidden when the animation completes. Plus: This won't work in IE <= 9, it does not support keyframe animations: http://caniuse.com/#feat=css-animation
@keyframes fadeInOut {
0% {
opacity: 0;
}
16% {
opacity: 1;
}
84% {
opacity: 1;
}
100% {
opacity: 0;
}
}
.message {
width: 400px;
margin: 0 auto;
opacity: 0;
text-align: center;
-webkit-animation: fadeInOut 6s;
animation: fadeInOut 6s;
}
Involving JS: http://jsfiddle.net/marionebl/P26c9/1/
Is somewhat more flexible and easier to change, supports IE9.
CSS:
@-webkit-keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@-webkit-keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.fadeIn {
-webkit-animation: fadeIn;
animation: fadeIn;
opacity: 1;
}
.fadeOut {
-webkit-animation: fadeOut;
animation: fadeOut;
opacity: 0;
}
.fast {
-webkit-animation-duration: 1s;
animation-duration: 1s
}
.message {
width: 400px;
margin: 0 auto;
text-align: center;
}
JS:
var $message = $('.message');
$message.addClass('fadeIn fast');
setTimeout(function(){
$message.removeClass('fadeIn').addClass('fadeOut');
}, 5000);
Code Example |
---|
Css :: hover |
Css :: text vs font properties in css |
Css :: image cut css |
Css :: divs overlapping on mobile landscape |
Css :: display: inline; |
Css :: acf wysiwyg height |
Css :: html incliude all css from folder |
Css :: highcharts change font family |
Css :: css stopper une animation |
Css :: can i merge background image background-image css |
Css :: CSS The object-fit Property |
Css :: abstände zwischen zeilen html |
Css :: enable xdebug ddev |
Css :: table vertical align center |
Css :: text overlay animation css |
Css :: height current -3px css |
Css :: css clamp vs media queries |
Css :: How to convert directory SASS/SCSS to CSS via command line? |
Css :: css font weight |
Css :: html color codes |
Css :: svg background css |
Css :: css border sides |
Css :: advance css |
Css :: background |
Css :: mouse hold css effect |
Css :: css add margin to a particular div in print screen |
Css :: css marker effect |
Css :: less variables vs css variables |
Css :: faunadb q.do |
Css :: css style nth child beyond certain number |