CSS3 filter blur keyframe animation

Jefferson picture Jefferson · Mar 14, 2013 · Viewed 22.7k times · Source

What I'm trying to accomplish is a short gaussian blur animation on an image hover. Somewhat like setting focus on a camera. (focused-blurred-focused).

This is what I got so far:

@-webkit-keyframes image_blur {
    0% { -webkit-filter: blur(0px);}
    50%; { -webkit-filter: blur(5px);}
    100% { -webkit-filter: blur(0px);}
}

#image {
    width    : 290px;
    height   : 160px;
    background: url(images/test1.jpg);
}

#image:hover {
    -webkit-animation: image_blur 2s; 
}

Which doesn't seem to be working. Any suggestions?

Answer

Simon Arnold picture Simon Arnold · Mar 14, 2013

Remove the ";" after "50%" in your @-webkit-keyframes.
It will work.

0% { -webkit-filter: blur(0px);}
50%; { -webkit-filter: blur(5px);}
100% { -webkit-filter: blur(0px);}

Use this instead

0% { -webkit-filter: blur(0px);}
50% { -webkit-filter: blur(5px);}
100% { -webkit-filter: blur(0px);}