Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
HTML5 Zone is brought to you in partnership with:

John Esposito curates content at DZone, while writing a dissertation on ancient Greek philosophy and raising two cats. In a previous life he was a database developer and network administrator. John is a DZone Zone Leader and has posted 268 posts at DZone. You can read more from them at their website. View Full User Profile

CSS3 Transitions, Hover Effects, and Two Different Kinds of Interactivity

11.10.2011
Email
Views: 2628
  • submit to reddit
The HTML5 Microzone is presented by DZone and Microsoft to bring you the most interesting and relevant content on emerging web standards.  Experience all that the HTML5 Microzone has to offer on our homepage and check out the cutting edge web development tutorials on Script Junkie, Build My Pinned Site, and the HTML5 DevCenter.

This CSS3 hover tutorial caught my eye -- but also fired a recent designer's rant in my memory. Why do these hover effects, by Alessio Atzeni, look cooler than these?

The former is animated, of course, while the latter is not. Animation alone increases the sense of interactivity -- from infancy, even. But then what's the difference between this animation (flying zoom) and this one (sideways slide)? The CSS elements themselves are straightforward (scale and translate with ease-in-out) -- but why use one and not the other?

These are designers' questions, I suppose, and accordingly rather beyond me. But comparing these two CSS hover tutorials (1,2), especially the multiple transition&animation variations demoed here, gives a clear sense of how CSS3 allows a small change in the developer's code to make a really significant difference in the user's experience.

Alessio's 'true bounce effect' in Example 8 is particularly neat. At the heart is this keyframe rule -- easy to understand in principle, but remarkably well executed:

@keyframes bounceY {
2	    0% { transform: translateY(-205px);}
3	    40% { transform: translateY(-100px);}
4	    65% { transform: translateY(-52px);}
5	    82% { transform: translateY(-25px);}
6	    92% { transform: translateY(-12px);}
7	    55%, 75%, 87%, 97%, 100% { transform: translateY(0px);}
8	}

The trick lies, obviously, in the exact relation between the timing percents and the translationY distances. Alessio doesn't explain exactly how he selected these numbers, but they were certainly well-chosen.

These are the kinds of super-concrete details I find especially helpful in a tutorial like this -- where individual tips are concrete, but surrounded by a large enough number of variations that very different pages can benefit from a considerable variety of user experiences produced by fairly similar bits of code. You might want to keep this tutorial page as a go-to guide for high-quality and easy-to-code CSS3 transition and animation effects.

 

Published at DZone with permission of its author, John Esposito.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

HTML5 is the most dramatic step in the evolution of web standards. It incorporates features such as geolocation, video playback and drag-and-drop. HTML5 allows developers to create rich internet applications without the need for third party APIs and browser plug-ins.  Under the banner of HTML5, modern web standards such as CSS3, SVG, XHR2, WebSockets, IndexedDB, and AppCache are pushing the boundaries for what a browser can achieve using web standards.  This Microzone is supported by Microsoft, and it will delve into the intricacies of using these new web technologies and teach you how to make your websites compatible with all of the modern browsers.