Picnic Website Code Tutorials

CSS3 Blinking Image With Keyframes Tutorial

12/12/2012

View Demo

Ta-Da! Pretty cool and pretty easy. Fading in/out image and CSS3 Keyframes animation written in shorthand. I've read that the shorthand order does not matter but I found otherwise. Safari needs the name to come first. Other than that, or when using both duration and delay, I don't think the order matters. This is how...

CSS

@-moz-keyframes blink {0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} /* Firefox */
@-webkit-keyframes blink {0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} /* Webkit */
@-ms-keyframes blink {0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} /* IE */
@keyframes blink {0%{opacity:1;} 50%{opacity:0;} 100%{opacity:1;}} /* Opera and prob css3 final iteration */
img {
border:1px solid #000;
-moz-transition:all 1s ease-in-out;
-webkit-transition:all 1s ease-in-out;
-o-transition:all 1s ease-in-out;
-ms-transition:all 1s ease-in-out;
transition:all 1s ease-in-out;
/* order: name, direction, duration, iteration-count, timing-function */  
-moz-animation:blink normal 2s infinite ease-in-out; /* Firefox */
-webkit-animation:blink normal 2s infinite ease-in-out; /* Webkit */
-ms-animation:blink normal 2s infinite ease-in-out; /* IE */
animation:blink normal 2s infinite ease-in-out; /* Opera and prob css3 final iteration */
}​
		

HTML

<img src="dont-blink.jpg" alt="Don't Blink">
		

Sponsors

Top Donators

Friends of Mine