Placed in: Home
The Apple.com navigation menu created using only CSS3

A while ago (I think it was around the release of the iPad), the Apple.com website got a new navigation menu on the top of the page. This menu bar was a lot darker than the previous, grey version, but looks just as great. One thing which I noticed about the navigation, is that the buttons are created out of images. That's the moment I thought we could do better, using some nifty CSS3 techniques. So today, I present you the Apple.com navigation menu created using only CSS3.

The Apple.com navigation menu created using only CSS3

Since this demo heavily relies on CSS3, make sure you view it using a CSS3 compatible browser. The Webkit browsers (Safari and Chrome) display the effect the best, followed by the latest version of Firefox. Opera and IE don't display everything correct, but the menu seems to be working.

Demo Apple.com CSS3 menu   Download Apple.com CSS3 menu

The menu on the Apple.com website also updated their search suggestion, which hasn't been implemented in this demo (yet), but I might create that later. For now, let's check out all the CSS3 you'll need to be able to create this fancy looking navigation menu.

Techniques

Before I'll let you dive into the CSS part of this technique, I want to point out a couple of techniques that are used in order to create the desired effect:

  • font - The same font from Apple has been used (with fallback for those computers where the font isn't installed), and is called Lucida.
  • text-shadow - A smooth text shadow is applied to the text placed on the buttons.
  • border-radius - The border radius is needed to create the rounded border on the first and last menu item, but also in the search bar.
  • box-shadow - This type of shadow is used in several places to create a subtle drop shadow effect.
  • box-shadow: inset - By using the inset property of a box shadow, we can create an inner shadow effect.
  • gradient - Gradients are used a lot on the demo page. Sadly, Webkit (Chrome and Safari) have a different syntax than Firefox. Luckily, this CSS3 Gradient Generator helped me out.
  • :first-child - This pseudo selector is used to only give the first item the rounded cornes.
  • :not(:last-child) - The :not selector filters the last child to act to hover events, since we don't need them there (it's the search bar).
  • background-image: url(), gradient() - Multiple backgrounds are applied to the search field, to show the magnifier and the gradient background.
  • keyframes - A nifty animation has been applied using keyframes to fade in the menu bar (the same kind of effect was used when the iPad was displayed on the front page of Apple.com). Take note this only works in Webkit browsers (Chrome and Safari).
  • Fallback - Fallbacks are pretty important for browsers that don't support the effect completely. I've used a solid background-color when the gradient wasn't support.

As you can see, a lot of CSS3 has been used here. Also, the high level of detail in the menu makes it look very pretty. Let's see how the final CSS looks like!

CSS

I've added comments to some parts to explain what it does.

 
/* APPLE STYLE NAVIGATION MENU */
#appleNav {
    margin:40px 0; list-style:none;
 
    /* Lucinda Grande is the font used on the website from Apple. */
    font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; letter-spacing:-0.5px; font-size:13px;
    
    /* Apply a subtle text-shadow to the text */
    text-shadow: 0 -1px 3px #202020;
 
    /* We want to add the shadow to the complete navigation menu. In order to do that, we'll need to set
    the correct width and height, and also the correct borders, in order to create the perfect drop shadow */
    width:980px; height:34px;
    
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    border-radius:4px;
    
    -moz-box-shadow: 0px 3px 3px #cecece;
    -webkit-box-shadow: 0px 3px 3px #cecece;
    box-shadow: 0 3px 4px #8b8b8b;
}
 
#appleNav li {
    display:block; float:left; border-right:1px solid #5d5d5d; border-left:1px solid #929292; width:105px; height:34px; border-bottom:1px solid #575757; border-top:1px solid #797979;
 
    /* Gradient backgrounds for the buttons. Generated using http://gradients.glrzad.com/ */
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
    background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
    background-color:#5f5f5f; /* Fallback */
}
 
/* Set the states when hovering, except for the last item in the list (the search bar), since it doesn't need to change */
#appleNav li:not(:last-child):hover {
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #3F3F3F), color-stop(0.5, #383838), color-stop(0.51, #434343), color-stop(1, #555555));
    background-image: -moz-linear-gradient(center bottom, #3F3F3F 0%, #383838 50%, #434343 51%, #555555 100% );
    background-color:#383838; /* Fallback */
    
    /* We use the inset of the box shadow to create a subtle inner glow when hovering */
    -moz-box-shadow: inset 0 0 5px 5px #535353;
    -webkit-box-shadow: inset 0 0 5px 5px #535353;
    box-shadow: inset 0 0 5px 5px #535353;
}
 
/* When the user clicks the button, we simply change the box inset (compared to the "hover") */
#appleNav li:not(:last-child):active {
    background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #3F3F3F), color-stop(0.5, #383838), color-stop(0.51, #434343), color-stop(1, #555555));
    background-image: -moz-linear-gradient(center bottom, #3F3F3F 0%, #383838 50%, #434343 51%, #555555 100% );
    background-color:#383838; /* Fallback */
    
    -moz-box-shadow: inset 0 1px 2px 2px #000;
    -webkit-box-shadow: inset 0 1px 2px 2px #000;
    box-shadow: inset 0 1px 2px 2px #000;
}
 
#appleNav li a {
    color:white; text-decoration:none; text-align:center; display:block; line-height:34px; outline:none; }
 
/* Styling of the search field */
#appleNav form input {
    width:76px; height:20px; margin-left:9px; margin-top:8px; border:none; padding-left:20px; padding-right:10px; color:#eee;
 
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
 
    /* We use the CSS3 multiple backgrounds for the input field: The magnifier image and the gradient background */    
    background-image: url("../images/magnifier.png"), -webkit-gradient(linear, left bottom, left top, color-stop(0, #747474), color-stop(0.5, #6E6E6E), color-stop(0.51, #7E7E7E), color-stop(1, #8D8D8D));
    background-image: url("../images/magnifier.png"), -moz-linear-gradient(center bottom, #747474 0%, #6E6E6E 50%, #7E7E7E 51%, #8D8D8D 100%);
    background-repeat: no-repeat;
    
    background-color:#6E6E6E; /* Fallback */
    
    -moz-box-shadow: inset 0 2px 1px 1px #363636;
    -webkit-box-shadow: inset 0 2px 1px 1px #363636;
    box-shadow: inset 0 2px 1px 1px #363636;
}
 
/* Rounded corner for the first in last item. Shorthand: Top left, Top right, Bottom right, Bottom left.
We also remove the borders, since they don't need them. */
#appleNav li:first-child {
    -moz-border-radius:4px 0 0 4px;
    -webkit-border-radius:4px 0 0 4px;
    border-radius:4px 0 0 4px;
    
    border-left:none;
}
 
/* The first child image - the logo - has to be centered. Because of the image dimensions, we manually need to shift it a bit. */
#appleNav li:first-child a img {
   vertical-align:middle; margin-top:-2px;
}
 
#appleNav li:last-child {
    -moz-border-radius:0 4px 4px 0;
    -webkit-border-radius:0 4px 4px 0;
    border-radius:0 4px 4px 0;
    
    border-right:none;
    
    /* The width of the last menu item (search bar) is bigger than the others */
    width:124px;
}
 
/* Fade in animation (Webkit only) */
@-webkit-keyframes showMenu {
    from { opacity: 0; top:-20px; }
    to   { opacity: 1; }
}
 
#appleNav {
     -webkit-animation: showMenu 1s; position:relative;
}

CSS

Conclusion

That's about it, everything you need to create a fully CSS3 powered Apple.com-style navigation menu! What do you think of it?

Demo Apple.com CSS3 menu   Download Apple.com CSS3 menu

Did you learn anything from the script? Do you see any room for improvement? Feel free to share!


Tags:  apple navigation menu css3

Interested in this topic? You might enjoy another article I've written called

Did you like this article? Subscribe to my feed or email to keep updated on new articles.

Spread the word and submit to:
Digg!Reddit!Del.icio.us!Facebook!StumbleUpon!
Comments
Add NewSearchRSS
Michael Martin - Pro Blog Design   2011-05-30 19:04:07
Gravatar image Awesome demo, it's come together perfectly! Kind of makes me wish they'd swap to your code!
Ben Collier   2011-05-30 21:13:21
Gravatar image Sweet! Maybe inline the two images in data URIs as base64 in the CSS and then it'd be even cooler.

Also adding:
Code:

#appleNav form input:focus{
width: 140px;
}

#appleNav form input{
-webkit-transition: all 500ms ease-in-out;
-moz-transition: all 500ms ease-in-out;
-o-transition: all 500ms ease-in-out;
transition: all 500ms ease-in-out;
}



Almost gives you the expanding search box; just needs a couple of tweaks.
Marco - Thanks   2011-05-31 07:23:34
Gravatar image I'm not a huge fan of base64 inside CSS, but that would work as well indeed :) . Could have taken care of use of any images at all!

Thanks for adding the code for the search animation; I've tried that as well, but the trick is that the other buttons should be downsized as well. I need some sort of parent-selector to do so, but that doesn't exsist in CSS.

So, I'll come up with a jQuery solution and combine it with the neat auto-complete some day ;) . Stay tuned!
Catalin - Nice demo   2011-06-02 16:44:43
Gravatar image Marco, nice demo, it looks very well.

For search box animation, I think that CSS3 Flexbox is the most suited to help you implement this scaling behavior.

Additionally, for non-suported browsers, a fallback with Modernizr will do it!

Just an idea, thanks for sharing this!
Felton   2012-06-08 19:02:22
Gravatar image How to I make the navigation recognize internet explorer?
Beben Koben - Prodigy of Head   2011-05-31 18:57:32
Gravatar image awesome master...it's great...APPLE :evil:
thanks for tut's B)
Antony Doyle - Pretty good.   2011-05-31 21:03:42
Gravatar image I'm not usually a fan of Apple type designs, but must say their menu is pretty sweet and your version is spot on. Great work.

If you fancied getting your CSS on, and removing the images, I recently found this;

http://nicolasgallagher.com/pure-css-gui-icons/

and this;

http://dribbble.com/shots/81213-Apple-logo-with-CSS

I don't think the search icon would be too difficult to impliment, though I think the Apple logo would wind up adding a larger chunk of code than the image would take up!
wanglin - chance TE   2013-06-10 16:00:00
Gravatar image study learn ervry thing!
wanglin   2013-06-10 16:00:46
Gravatar image You are wrong!
Thomas - Amazing   2011-06-15 10:24:09
Gravatar image Thanks, I've been trying to do this my self, but ended up having to use images that changed when hovered over.

Could you try and do the menu that's at the top of the iTunes store window? It's probably much harder, but just asking.
Anonymous   2011-06-24 01:37:15
Gravatar image I Don't Know What You Say,You Can try to do it ,thanks
Thomas - Sorry?   2011-06-29 07:32:44
Gravatar image Sorry? :huh:

Don't worry, I'm having another go at the iTunes menu bar, it's harder but seems to use similar code. :confused:

I was using a add on for Dreamweaver to attempt this, it works alright but not good enough... :0
Tamixes - How to make IE behave   2011-06-16 12:32:26
Gravatar image CSS3 PIE is a great way to get IE to display some of the CSS3 properties that other browsers use
http://css3pie.com/
Siddhartha Sinha - Nice Theme   2011-06-24 23:51:24
Gravatar image This CSS is good to get Apple theme
madhav - Excellent menu   2011-06-25 03:59:47
Gravatar image Apple should be stunned by seeing this menu, how is it possible with only css. But the css coding is little bit tough for beginners.A thought and an experiment of doing like apple menu is an achievement we have to say.
uklam - nice   2011-06-25 20:09:01
Gravatar image wow amazing , i will try it someday B)
affordable web designer - Amazing   2011-07-06 15:53:58
Gravatar image Thanks, I've been trying to do this my self, but ended up having to use images that changed when hovered over.
blokefrompoland   2011-07-18 20:27:08
Gravatar image I've tried something similar a couple of months ago and just recently pushed it to GitHub.

Here's the page:

http://blokefrompoland.github.com/apple.com-css3-menu/

Let me know what do you think.
Harald   2012-04-24 23:35:05
Gravatar image I like this version very much. Implemented it on my site. One question though. I would like the magnifier to be white when not active, like it is on the apple site. How do I do that?
Jasse - Nice Menu Mate   2011-07-19 16:21:27
Gravatar image I knew CSS3 is quite powerful.
Bongo - Thanks for share   2011-08-05 07:53:59
Gravatar image Cool... ... I love it! :)
Zak - Apple Menu is sleek   2011-08-08 17:40:09
Gravatar image Apple menu is sleek and simple and with CSS3 you have done a great job.
whaze - Thanks for that share..   2011-08-27 22:52:40
Gravatar image Very Cool tutorials as we know apple is bigger tech company in the world anyone want to have apple style thanks for all work :D.
Very nice B)
design - Very beautiful   2011-08-31 06:56:17
Gravatar image Its very beautiful navigation.
Francesco - Beautiful   2011-09-13 07:52:13
Gravatar image In Safari it looks very very good, but in IE 9 it's terrible what a pity. Good work
Jacob - Good Design - CSS3 Now   2011-10-08 17:39:29
Gravatar image Its pleasing to see how CSS3 has made things simple and powerful to create great artwork. If you like more art work then check

http://awaltechnologies.com

as they are specialist in creating great pieces of artwork for web-sites.
Nora Reed - hi   2011-10-10 10:24:24
Gravatar image This is great to know! n thanks for sharing this Css coding : )
Jimmy Brake - if you want to make the menu dynamic ...   2011-10-26 16:28:54
Gravatar image I am using prototype ... I think the jquery foo would be similar ...

I changed wrapper to navwrapper (it conflicted)











{THE_SUB_MENU_NAME}








// get the sum of the widths in the topNav then apply that to appleNav(so the shadow looks proper)

var total = 0;
var width = 0;

for (var index = 0, len = $$('li.topNav').length; index < len; ++index) {
var item = $$('li.topNav')[index];
width = item.getWidth();
total = width + total;
}

$('appleNav').setStyle({ width: total + 'px' });

johns - Online Gadgets Magazine   2011-10-26 19:25:49
Gravatar image same for me, I had trouble getting it to work properly into ie9
johns - Online Gadgets Magazine   2011-10-26 19:27:14
Gravatar image same for me, I had trouble getting it to work properly into ie9
Gagandeep - Navbar For Blogger   2011-10-28 09:56:00
Gravatar image Hey great work man!!
I was wondering if you can create a widget for blogger to insert this navbar....coz i just messed up my blog doing this...and i didn't even have a backup...plzzzz create one...
java guy - Java Guy   2011-11-16 20:29:13
Gravatar image It doesn't work on IE. does anyone know of making it work on IE?
Guest - Active status   2012-02-18 14:33:07
Gravatar image Hi there,

When I click the button it performs the active status.

Now when I want to show the button as selected on the page I'm on, it doesn't work.
I just added class="active" to the for testing purposes like this:
Code:

Beer


What did I do wrong?

Can you show me an example to do it correct?

Thanks!
Guest   2012-02-18 14:33:54
Gravatar image Code didn't show up right:

Beer
Guest   2012-02-18 14:34:40
Gravatar image Last try...

Quote:

Test
Joe Khoury   2012-02-18 22:02:12
Gravatar image what if i want the last time to hover also, which part of the code should i change?
thank you
denish - please give me solution   2012-02-20 11:33:39
Gravatar image hey bro can i change this menubars black color into green.
please give me aswer......

thanks for apple menubar coding
Alex - Alex   2012-02-29 13:34:40
Gravatar image Great tutorial.
Gonna use in my upcoming designs.

Thanks
John   2012-03-12 14:51:15
Gravatar image Great Work..
It's Fantastic menu...........
prashanth reddy - html code?   2012-03-15 20:47:03
Gravatar image [size=large]dude , i added css code into my website
but ,what is the html code to display it?[/size]


-------------------------
after adding css code, how to display it

please give me answer......
Daniel - ANSWER   2012-04-18 15:22:21
Gravatar image Hello,

You just download the source code. Here's a link. http://www.marcofolio.net/downloads/css/apple.com_css3_menu/download.html

Or go to the top of this page:
Posted image
prashanth reddy   2012-03-15 20:47:37
Gravatar image , i added css code into my website
but ,what is the html code to display it?[/size]


-------------------------
after adding css code, how to display it

please give me answer......
Daniel - ANSWER ABOVE   2012-04-18 15:24:46
Gravatar image Hello,

Just posted the answer to your question!

If you look above this post - you can see it!

ATB
Daniel
Daniel - How do you get rid of the search bar bit?   2012-04-18 15:10:27
Gravatar image Hi,

Really like it all - but was just wondering if there's a way to get rid of the search bar bit?

I am just wanting to have a cool menu bar - and don't need the search bit.
Any help would be much appreciated!

Thanks.
Rich - No IE support   2012-04-23 18:23:59
Gravatar image Not very useful if it can't support IE which has over 50% of the browser market share.
Tony - Really?   2012-04-23 18:51:33
Gravatar image Firstly, IE has about 30%, not 50%. (src: http://www.w3counter.com/globalstats.php).

Secondly, it does work in IE, it just doesn't look all that pretty. All you have to do is add an IE only stylesheet to tidy it up. Should take all of 5 minutes.

Thirdly, there are plenty of sites that don't support IE at all out there, and given that out of the aforementioned 30% most of that is probably IE8 and below, they will be used to a horrendous browsing experience already, so a not-so-pretty menu will be the least of their worries.

If, for some reason, you still want it to look identical in every browser, use images instead.
Tilda - How to highlight active tab   2012-05-18 22:13:45
Gravatar image This is just what I wanted. Thanks for a great job. Two questions.
1. Is there a way to highlight the active tab?
2 Is it possible to make the background white in the search box when clicked on?
Tilda   2012-05-18 22:15:12
Gravatar image This is just what I wanted. Thanks for a great job. Two questions.
1. Is there a way to highlight the active tab?
2 Is it possible to make the background white in the search box when clicked on?
Tilda - Solved   2012-05-18 22:34:44
Gravatar image Solved it with this code
#appleNav form input:focus{
outline: none;
width: 140px;
background: #ffffff;
}
Tilda - Sorry   2012-05-18 23:01:56
Gravatar image Sorry, I solved only the second question not the first.
Alex - Blank spaces   2012-06-05 10:35:36
Gravatar image Anyone got any ideas on how to join 2 of the buttons together to create a blanking space not changing on hover. I want 4 sections on one side, 3 blanks all joined together then one for logout.
ToTo Antonio - Thank You   2012-06-23 17:33:15
Gravatar image This is what i've been looking for a long time. Thank You very much for sharing. Worked without issues for me..
Shane - Width   2012-07-15 11:27:47
Gravatar image I'm adding this menu to a phpbb style which has a width of 80%. I extended the width property on the menu but it only extended the shadow. How can I get it to shift everything and float the search to the right.

Thanks
jake   2012-08-12 00:24:14
Gravatar image So did we ever figure out how to get the search bar to expand like the current apple.com site and then display in FF, Chrome, and IE
luke - spry menu?   2012-08-28 03:15:07
Gravatar image A good addition to this would be a spry menu.
anyone made one and want to share?
Jude - Highlight Active Tab   2012-09-17 20:52:31
Gravatar image Can anyone help me highlight the active tab? Thanks! Will be very much appreciated! :?:
Chris - Remove Search section   2012-09-19 17:35:53
Gravatar image This is a great menu. I saw someone else ask about removing the search feature. I have been playing with with css and the last child section I think this is what is generating the search part. I have not having any luck removing it. Any help would be great.
MARLNE - color change   2013-02-16 04:22:08
Gravatar image is there an easy way to change the colour
pepote - sub menu   2013-04-12 10:51:50
Gravatar image Since podria this menu puts with a sub menu I need it urgently thank you
Atinder - css3 Menu   2013-04-13 12:17:05
Gravatar image Thanks for your tutorial css3 Menus
Neha sharma - Thinkala   2013-04-13 12:18:49
Gravatar image Your tutorial of [http://thinklala.blogspot.in/2013/04/20-pure-css3-menu-design.html]css3 Menus[/url] is really helpful
Scott - Marco - Design help   2013-04-29 19:36:50
Gravatar image Hi, im attempting to make some changes to the appearance for our own site. Can I higher you to help me with this? Thanks!
Methanide - nav bar color   2013-04-30 15:00:49
Gravatar image If i wanted to change the color from the grey tones to a blue tone, how would I do that? I am just starting out and would love the feeedback thanks.
dever - awesome.. :)   2013-05-29 15:41:51
Gravatar image man u r so gr8 ... i love the menu ... but i still need the footer look.. i mean the lined upper and under the links and betwen ... how to do that ?
goldie - Centering   2013-06-17 20:26:34
Gravatar image CAN ANY ONE TELL ME HOW TO CENTER THIS MENU IV BEEN TRYING FOR MONTHS IT WILL NOT CENTER ON EVERY DEVICE I HAVE TO PUT LEFT: -50PX; TO GET IT ALMOST IN THE MIDDLE BUT ON OTHER DEVICES WITH LARGE SCREEN RESOLUTIONS ALL THE CONTENT IS IN THE MIDDLE BUT THE MENU IS OVER ON ONE SIDE ITS CRAZING ME
Read more...
Name:
Email:
  Gravatar enabled.
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Security Image
Please input the anti-spam code that you can read in the image.
Unsubscribe from e-mail notifications.
 
< Prev   Next >
Subscribe

Subscribe to Marcofolio