, ,

Enhance navigation and links using the CSS3 transition property

header-enhance

In the following quick tip I’ll explain something about using CSS3 transitions for navigation and hovering links.  Most of these quick tips are used in the M-Sign theme, which is used by this site and is available for download!

CSS3 covers a nifty new (well, relatively new) property which enables smooth transitions between different states of a styled element. Let’s say you have a certain div element which changes it background on hovering. Normally, there would be no transition and the background would be immediately changed on hovering. Using transition, we can have control on the speed of this transition (between unhovered and hovered state), the way it transits and how long the transition is delayed. In short, for all browsers an example:


div {
transition: all 2s ease-out 2s;
/* IE 10 */
-ms-transition:all 2s ease-out 2s;
/* Firefox 4+ */
-moz-transition:all 2s ease-out 2s;
/* Opera */
-o-transition:all 2s ease-out 2s;
/* Safari and Chrome */
-webkit-transition:all 2s ease-out 2s;
}

This transits all properties of the given element (div) during 2 seconds, the transition animation will easy out and the animation will start after two seconds. Basically, the shorthand is constructed likewise:


transition: || transition-property || transition-duration || transition-timing-function || transition-delay;

For more background on the transition properties, look at the W3schools page on css transitions.

So how can we apply this to enhance our navigation? Well, for example to add transition to link (a) selectors which change properties during hovering.
Let’s say a link change color, as in the following example:


a {
color: #777;
}
a:hover {
color: #F07;
}

Adding the following transition property will let this link gradually change color, but also e.g. a background if this was used (since the transition-property is set on ‘all’!):

a {
transition: all 1000ms ease-out;
-webkit-transition: all 1000ms ease-out;
-moz-transition: all 1000ms ease-out;
-ms-transition: all 1000ms ease-out;
-o-transition: all 1000ms ease-out;;
}

This transition will, in my belief, enhance the interactivity and experience of navigation little, and make it more ‘comfortable’ to hover links.The example is used within the top navigation menu of m-sign, but also for the subscribe links on the right of the header of this site. I hope I could have given you a glimpse of how to enhance navigation and link-hovering, and good luck webdesigning!

About Michiel

Michiel is studying a Master in Strategic Product Design and interested in the fields of design, psychology and faith. He became a child of God through Jesus in 2004. He has experience in graphic designing and webdesign, and a degree of industrial design; which enables him to think from the perspective of to user and to solve problems with creativity.

3 Responses to Enhance navigation and links using the CSS3 transition property

Leave a reply
  1. Ha Michiel! Goed bezig man!! Werkt die hover transitie ook bij touch? Bekijk het nu op mn iPad en zie daar geen transities. Touch en muis effecten / interactiviteit lijken nog twee aparte eilandjes te zijn.

    • Oops, iets te snel. Bij het allerbovenste menu zie je idd wel een geleidelijke transitie naar felroze. Alleen pas op touch en niet op hover, hoewel die twee eigenlijk hetzelfde zijn voor touchscreens haha ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>