html - Animate css on page load -


is possible action css animation when page loads? i'm exploring css animations right have never worked them.

so far have created this: https://jsfiddle.net/7prg793g works hover over.

* {   margin: 0;   padding: 0; }  .reveal {   width: 380px;   height: 660px;   margin: 50px;   float: left; }  .open {   background: url(http://uploadir.com/u/9btuxs9t) 0px 330px, url(http://uploadir.com/u/9btuxs9t) 0px -405px, #42413c;   background-repeat: no-repeat;   -webkit-transition: background-position 0.3s ease;   -moz-transition: background-position 0.3s ease;   -o-transition: background-position 0.3s ease;   -ms-transition: background-position 0.3s ease;   transition: background-position 0.3s ease; }  .open:hover {   background: url(http://uploadir.com/u/9btuxs9t) 0px 660px, url(http://uploadir.com/u/9btuxs9t) 0px -735px, #42413c;   background-repeat: no-repeat; }  .reveal p {   font: 45px/300px helvetica, arial, sans-serif;   text-align: center;   -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=0)";   filter: alpha(opacity=0);   opacity: 0;    -webkit-transition: 0.3s ease;   -moz-transition: 0.3s ease;   -o-transition: 0.3s ease;   -ms-transition: 0.3s ease;   transition: 0.3s ease; }  .reveal:hover p {   -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=100)";   filter: alpha(opacity=100);   opacity: 1;   cursor: pointer; } 

if possible, next question possible delay animation until div visible? i'm going using preloader before hand.

thank you.

pure css solution (keyframes)

this solution okay depends compatibility want browsers:

@keyframes opening {     0% {           background: url(http://uploadir.com/u/9btuxs9t) 0px 330px, url(http://uploadir.com/u/9btuxs9t) 0px -405px, #42413c;     }     100% {        background: url(http://uploadir.com/u/9btuxs9t) 0px 660px, url(http://uploadir.com/u/9btuxs9t) 0px -735px, #42413c;     } }  @keyframes opening-p {     0% {       -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=0)";       filter: alpha(opacity=0);       opacity: 0;         }     100% {       -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=100)";       filter: alpha(opacity=100);       opacity: 1;     } } 

i created 2 keyframes use animation div , text. after attached animation in way (using animation-fill-mode:forwards;)

.open {     background: url(http://uploadir.com/u/9btuxs9t) 0px 330px, url(http://uploadir.com/u/9btuxs9t) 0px -405px, #42413c;   background:no-repeat;   -webkit-transition: background-position 0.3s ease;   -moz-transition: background-position 0.3s ease;   -o-transition: background-position 0.3s ease;   -ms-transition: background-position 0.3s ease;   transition: background-position 0.3s ease;   animation-name: opening;   animation-iteration-count: 1;   animation-duration: 1s;   animation-fill-mode: forwards; }  .reveal p {   font: 45px/300px helvetica, arial, sans-serif;   text-align: center;   cursor:pointer;    -webkit-transition: 0.3s ease;   -moz-transition: 0.3s ease;   -o-transition: 0.3s ease;   -ms-transition: 0.3s ease;   transition: 0.3s ease;    animation-name: opening-p;   animation-iteration-count: 1;   animation-duration: 1s;   animation-fill-mode: forwards; } 

here fiddle: http://jsfiddle.net/8anvmpfv/

jquery solution

so it's easy jquery:

  $('.reveal').ready(function() {       $('.reveal').addclass('opened revealed');   }); 

it waits div ready , jquery give div right class animation css. here fiddle: https://jsfiddle.net/k6faf0fu/


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -