Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
With the below CSS i am trying to hide the div after 5 seconds. But it works only with Chrome.

Problem:
It will not work with IE and Firefox, It will hide the div but space remains. please help.


What I have tried:

<div class="success">Successfully saved</div>

.success {
  -webkit-animation: seconds 1.0s forwards;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-delay: 5s;
  animation: seconds 1.0s forwards;
  animation-iteration-count: 1;
  animation-delay: 5s;
  position: relative;
    
}
@-webkit-keyframes seconds {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: -9999px; 
    position: absolute;   
  }
}
@keyframes seconds {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: -9999px;
    position: absolute;     
  }
}
Posted
Updated 9-Mar-17 0:30am
v2
Comments
[no name] 9-Mar-17 5:55am    
For your reference please find the below CSS:

<div class="success">Successfully saved</div>


.info, .success, .warning, .error, .validation {
  -webkit-animation: seconds 1.0s forwards;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-delay: 5s;
  animation: seconds 1.0s forwards;
  animation-iteration-count: 1;
  animation-delay: 5s;
  position: relative;
    
}
@-webkit-keyframes seconds {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: -9999px; 
    position: absolute;   
  }
}
@keyframes seconds {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    left: -9999px;
    position: absolute;     
  }
}
F-ES Sitecore 9-Mar-17 6:02am    
According to this you need to define it for each browser as they seem to support different syntax.
Richard Deeming 9-Mar-17 10:43am    
It looks like that's an old article. According to Can I use[^], Chrome hasn't needed the -webkit- prefix since v43; Firefox hasn't needed the -moz- prefix since v16; Edge, IE10 and IE11 don't need a prefix; and IE9 and below doesn't support CSS animation at all. :)

1 solution

Than defining for each browser Jquery is better.

 $(document).ready(function () {          

            setTimeout(function() {
                $('.success').slideUp("slow");
            }, 5000);
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900