In this tutorial I will show you how to create animated 3D navigation menu (with images) with CSS3 only (JavaScript-free ). We will be using the power of CSS3 effects like perspective, box-sizing, transforms, gradients and transitions. You can use this menu in order to make a professional look of your website. Pay attention, than to see this menu you should move and hover your mouse over the blue element at the top of page.
This is our final result:

Here are samples and downloadable package:
[sociallocker]
[/sociallocker]
Step 1. HTML
The first step is to define the HTML markup.
index.html
04 | < meta charset = "utf-8" /> |
05 | < title >CSS3 3D top shift menu | Script Tutorials</ title > |
06 | < link href = "css/layout.css" rel = "stylesheet" type = "text/css" /> |
07 | < link href = "css/menu.css" rel = "stylesheet" type = "text/css" /> |
09 | < body class = "menu_body" > |
13 | < li >< a href = "#" >< img src = "images/1.png" /></ a ></ li > |
14 | < li >< a href = "#" >< img src = "images/2.png" /></ a ></ li > |
15 | < li >< a href = "#" >< img src = "images/3.png" /></ a ></ li > |
16 | < li >< a href = "#" >< img src = "images/4.png" /></ a ></ li > |
17 | < li >< a href = "#" >< img src = "images/5.png" /></ a ></ li > |
18 | < li >< a href = "#" >< img src = "images/6.png" /></ a ></ li > |
19 | < li >< a href = "#" >< img src = "images/7.png" /></ a ></ li > |
22 | < div class = "page_content" > |
23 | < div class = "shade" ></ div > |
25 | < div class = "header" >Box header</ div > |
29 | < div class = "footer" >Box footer</ div > |
32 | < div class = "header" >Box header</ div > |
36 | < div class = "footer" >Box footer</ div > |
In the body of the document we have the menu and page_content element. Main idea is to divide the page into two semantic sections. The main menu consists of UL-LI unordered list elements. Each element has own image.
The page contains of the shade element (which is invisible by default) and rest code (I prepared two design boxes here). Each box contains – the header, the body and the footer.
Step 2. CSS
I want to notice that current menu should work well in most of the modern web browsers (except IE). The best results are in Firefox and Chrome.
Now – let’s start styling the navigation menu! First, we write the rules for document’s BODY element:
3 | -webkit-perspective: 1500px ; |
4 | -moz-perspective: 1500px ; |
5 | -ms-perspective: 1500px ; |
6 | -o-perspective: 1500px ; |
It adds perspective to our page. Now we have to write the base rules for our menu and even for content section:
01 | .menu, .page_content { |
03 | -webkit-box-sizing: border-box; |
04 | -moz-box-sizing: border-box; |
05 | -ms-box-sizing: border-box; |
06 | -o-box-sizing: border-box; |
07 | box-sizing: border-box; |
08 | -webkit-transition: -webkit-transform 0.5 s ease; |
09 | -moz-transition: -moz-transform 0.5 s ease; |
10 | -ms-transition: -ms-transform 0.5 s ease; |
11 | -o-transition: -o-transform 0.5 s ease; |
12 | transition: transform 0.5 s ease; |
16 | background-color : #002edb ; |
23 | -webkit-transform: rotateX( -45 deg) translateY( -95% ); |
24 | -moz-transform: rotateX( -45 deg) translateY( -95% ); |
25 | -ms-transform: rotateX( -45 deg) translateY( -95% ); |
26 | -o-transform: rotateX( -45 deg) translateY( -95% ); |
27 | transform: rotateX( -45 deg) translateY( -95% ); |
31 | background-color : #4169ff ; |
33 | -webkit-transform: rotateX( 0 deg); |
34 | -moz-transform: rotateX( 0 deg); |
35 | -ms-transform: rotateX( 0 deg); |
36 | -o-transform: rotateX( 0 deg); |
37 | transform: rotateX( 0 deg); |
Please notice that we use rotateX and translateY properties to show and hide the main menu. Now, we should prepare the rules for our unordered list with images:
11 | list-style : none outside none ; |
14 | -webkit-transition: all 0.5 s ease; |
15 | -moz-transition: all 0.5 s ease; |
16 | -ms-transition: all 0.5 s ease; |
17 | -o-transition: all 0.5 s ease; |
18 | transition: all 0.5 s ease; |
21 | background-color : #7e00d6 ; |
23 | -webkit-border-radius: 64px ; |
24 | -moz-border-radius: 64px ; |
25 | -ms-border-radius: 64px ; |
26 | -o-border-radius: 64px ; |
We use easy transition for our images – we change color and set the radius for them. When we keep our mouse over the menu – we should make the page a little bit darker (we are going to use the shade element – gradient):
02 | .page_content .shade { |
13 | background : -moz-linear-gradient( top , rgba( 0 , 0 , 0 , 0.15 ) 0% , rgba( 0 , 0 , 0 , 0.65 ) 100% ); |
14 | background : -webkit-gradient(linear, top top , bottom top , color-stop( 0% ,rgba( 0 , 0 , 0 , 0.15 )), color-stop( 100% ,rgba( 0 , 0 , 0 , 0.65 ))); |
15 | background : -webkit-linear-gradient( top , rgba( 0 , 0 , 0 , 0.15 ) 0% ,rgba( 0 , 0 , 0 , 0.65 ) 100% ); |
16 | background : -ms-linear-gradient( top , rgba( 0 , 0 , 0 , 0.15 ) 0% ,rgba( 0 , 0 , 0 , 0.65 ) 100% ); |
17 | background : -o-linear-gradient( top , rgba( 0 , 0 , 0 , 0.15 ) 0% ,rgba( 0 , 0 , 0 , 0.65 ) 100% ); |
18 | background : linear-gradient(to bottom , rgba( 0 , 0 , 0 , 0.15 ) 0% ,rgba( 0 , 0 , 0 , 0.65 ) 100% ); |
20 | -webkit-transition: all 0.5 s ease; |
21 | -moz-transition: all 0.5 s ease; |
22 | -ms-transition: all 0.5 s ease; |
23 | -o-transition: all 0.5 s ease; |
24 | transition: all 0.5 s ease; |
And finally, we should enable our Shade and also we should rotate our page_content element when we hover the menu:
02 | .menu:hover ~ .page_content { |
04 | -webkit-transform: rotateX( -45 deg) translateY( 80px ); |
05 | -moz-transform: rotateX( -45 deg) translateY( 80px ); |
06 | -ms-transform: rotateX( -45 deg) translateY( 80px ); |
07 | -o-transform: rotateX( -45 deg) translateY( 80px ); |
08 | transform: rotateX( -45 deg) translateY( 80px ); |
11 | .menu:hover ~ .page_content .shade { |
In the long run our animated 3D CSS3 menu is complete!
Conclusion
Have you liked this tutorial? If so – make sure to share it with your friends and share your thoughts in the comment section below.