How to build a Cool Animated CSS3 Menu with no Javascript

March 18, 2010 - 27 CommentsWritten by

Earlier this week we published a post entitled 15 CSS3 Navigation and Menu Tutorials and Techniques, it is an exciting look at the possibilities and capabilities of CSS3 navigation in the near future. But, we did miss one tutorial from that list, and it is that tutorial that we publishing today.
This CSS3 tutorial was originally written in German by the Webstandard-Team, and they have kindly allowed us to translate it and publish it here. It certainly does deserve to be viewed by a wider audience.

Cool Animated CSS3 Menu Tutorial

This tutorial is about understanding, learning and mastering the some of the new features and properties of CSS3.
You will learn how to build a cool rounded navigation menu, with no images and no Javascript, and effectively make use of the new CSS3 properties border-radius and animation.

This menu works perfectly well with Chrome and Safari. With Firefox the border-radius works great but not the animation.

CSS3 Animated Menu

Step 1: The HTML structure of the Navigation

The basic HTML structure of the menu has three list items with the fictitious names “brand“, “promotion” and “event“.


How the menu looks so far:
CSS3 Animated Menu

Step 2: Create the Background Color of the Menu

In this step we are going to give the main navigation area (.css3Tutorial) a dark background.
The width, height and padding are completely optional, they are only there for demonstartion purposes when viewing the demo.

.css3Tutorial {
background: #14080a;
width:506px;
height:260px;
padding:20px;
}

How the menu looks so far:
CSS3 Animated Menu

Step 3: Round Navigation with border-radius

Now we will make each .li (navigation item) rounded with some cool CSS3 magic, more specifically with the border-radius property:
So far, the navigation will work very well with Chrome, Safari and Firefox.

ul {
list-style: none;
}
li {
float:left;
font: 14px/10px Arial, Verdana, sans-serif;
color:#FFF;
background-color: #b6f5fe;
width: 80px;
height: 80px;
padding:20px;
margin:0 30px 0 0;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
border-radius: 60px;
}

How the menu looks so far:
CSS3 Animated Menu

Step 4: Aligning the Navigation Points

In this fourth step, we will give each .li element (navigation item) a unique background-color and position:

li#brand {
background-color: #e1f5b8;
}
li#promotion {
background-color: #b6f5fe;
margin-top:100px;
}
li#event {
background-color: #f9bde6;
margin-top:50px;
}

How the menu looks so far:
CSS3 Animated Menu

Step 5: Aligning the Links within the Menu

li a {
color:#FFF;
text-decoration:none;
display:block;
width: 80px;
height: 45px;  text-align: center;
padding:35px 0 0 0;
margin:0 40px 0 0;
-webkit-border-radius: 40px;
-moz-border-radius: 40px;
border-radius: 40px;
}
li#brand a {
background-color: #afe43f;
}
li#promotion a {
background-color: #03aec7;
}
li#event a {
background-color: #ba1886;
}

How the menu looks so far:
CSS3 Animated Menu

Step 6: Define the Properties for the Hover Effect

In terms of a “good user experience” we will now add the hover effect for the “inner core” of our navigation:

li a:hover,
li a:focus,
li a:active {
width: 120px;
height:65px;
padding:55px 0 0 0;
margin:-20px 0 0 -20px;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
border-radius: 60px;
}

How the menu looks so far:
CSS3 Animated Menu

Step 7: Adding the animation to the Navigation

Now this were the navigation really comes alive. The animation property for this navigation works perfectly with Chrome anf Safari, but struggles with Firefox.

li a:hover,
li a:focus,
li a:active {
-webkit-animation-name:bounce;
-webkit-animation-duration:1s;
-webkit-animation-iteration-count:4;
-webkit-animation-direction:alternate;
}
@-webkit-keyframes bounce{from{margin:0 40px 0 0;}
to{margin:120px 40px 0 0;}
}

How the final menu looks:
CSS3 Animated Menu

Conclusion

So, there you have it, you have now learned how to build a cool Sliding Navigation, using no Javascript, no images and only powered by some really cool CSS3 properties.
Please remember this menu is only a concept, and has not be built for usage in the wild. We are going to have to wait, Chrome and Safari aside, for all browsers to catch-up to be able use all of the cool CSS3 features. I can’t wait!

About the Developers

CSS3 Animated Menu
The authors of this CSS3 tutorial have been the Webstandard-Team, a group of web developers from Berlin, Germany. You can follow them on Twitter and you can visit their excellent website Webstandard-Blog, a German written Blog about Web Design, Web Standards, Accessibility & Usability.

You might also like…

15 CSS3 Navigation and Menu Tutorials and Techniques »
20 CSS3 Tutorials and Techniques for Creating Buttons »
24 CSS (in some cases with jQuery) Navigation and Menu Tutorials »
22 CSS Button Styling Tutorials and Techniques »
CSS References, Tutorials, Cheat Sheets, Conversion Tables and Short Codes »
50 Useful Tools and Generators for Easy CSS Development »
50 Essential Web Typography Tutorials, Tips, Guides and Best Practices »
The Blueprint CSS Framework – Tutorials, How-to Guides and Tools »
20+ Resources and Tutorials for Creative Forms using CSS »

About the Author: (832 Articles)

Paul Andrew is the editor and founder of Speckyboy Design Magazine. You can follow Speckyboy on Twitter, on Facebook, on Digg or you can subscribe via RSS.

Comments and Reactions