I'm Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with HTML, CSS and SVG. To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

my books

Pro CSS3 Animation book coverPro CSS3 Animation, Apress, 2013

my other blogs

Massive Head CanonMassive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New DefaultsThe New Defaults — A Sass color keyword system for designers.

CSSslidyCSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

Animating CSS Background Blend Modes

Speed imparted with blends and background motion

There are only a few CSS background properties that can be animated: background-position, background-size, and background-color. With the addition of background-blend-mode to the CSS spec, this has been expanded slightly, albeit with limitations: we can only animate the property by alternating between blend modes and a value of normal. However, it’s also possible to animate background blends by using the other properties.

As one example, we might provide an enhanced impression of speed by altering background-position after hovering over a <div>:

div#runner { 
position: relative;
padding-top: 45%;
background: url(runner-long-distancw.jpg),
linear-gradient(90deg, #fff 50%, #000 50.5%);
background-size: cover, 20% 100%; 
background-blend-mode: difference; transition: 2s;
background-position: 200px 0px, 0px top; 
background-repeat: no-repeat, repeat-x;
}
div#runner:hover { background-position: -200px 0px, 200px top; }

… which results in the example you can see above. Obviously this particular effect needs to be employed with care, as the motion may affect those with vestibular disorders and light-sensitive epilepsy.

This is only an initial stab at the effects possible with background-blend-mode: I’ll be showing more very soon.

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.