Create a Fancy Menu with CSS3 and JQuery tabs

Last week I started this tutorial but I didn’t had the time to finish it. But today finally I’ve done it.
So what is this tutorial about?
We will create a couple tabs each one with it’s one content. It can be used as a menu or as simple tabs.

From CSS we will use a lot :before and :after pseudo-elements, gradient property and border-radius.

Here is the full demo example.

This is how our final work will look like.

First: the HTML

<div id="wrapper">
 <ul class="menu">
  <li><a href="#tabs-1">Nunc tincidunt</a></li>
  <li><a href="#tabs-2">Proin dolor</a></li>
  <li><a href="#tabs-3">Aenean lacinia</a></li>
  <div style="clear:both"></div>
  <div class="menu_content">
  <div id="tabs-1">
   <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
  <div id="tabs-2">
   <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
   <div id="tabs-3">
     <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
     <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>

As you can see the HTML format it’s not that complicated. I have created the usual wrapper which will hold the entire content.
Afterwards I created a list with class menu. Here we will have the ul li list which will be our main navigation. Then for each li and a tag I have created an div which holds paragraph’s with text. Of course in those div's you can insert what content you like.

This is the default format for JQuery tabs if you will go to the JQuery Tabs you will find an default example with the same format.

This is what we achieved so far.

Secondly: The CSS:

.menu {
 list-style: none outside none;
 margin: 60px auto 0;
 width: 660px;
.menu li {
 float: left; 
 position: relative;
.menu li:first-child:before,
.menu li:first-child a:before,
.menu li:last-child:after,
.menu li:last-child a:after,
.menu .ui-state-active:after,
.menu .ui-state-active:before,
.menu .ui-state-active a:after,
.menu .ui-state-active a:before {
 content: "";
.menu li:before,
.menu li:after,
.menu li a:before,
.menu li a:after {
 position: absolute;
 bottom: 0;
.menu li:before,
.menu li:after {
 background: #2f2f2f;
 width: 10px;
 height: 10px;
.menu li:before {
 left: -10px;
.menu li:after {
 right: -10px;
.menu li:last-child a {
 border-radius:0px 15px 0 0;
 -webkit-border-radius:0px 15px 0 0;
 -moz-border-radius:0px 15px 0 0;
 -khtml-border-radius:0px 15px 0 0;		
.menu li:first-child a {
 border-radius:15px 0px 0 0;
 -webkit-border-radius:15px 0px 0 0;
 -moz-border-radius:15px 0px 0 0;
 -khtml-border-radius:15px 0px 0 0;		
.menu a {
 float: left;
 padding: 10px 40px;
 text-decoration: none;
 text-shadow:1px 1px 1px #000;
 background: -webkit-gradient(linear, left top, left bottom, from(#4b4b4b), to(#2f2f2f)); /* for webkit browsers */
 background: -moz-linear-gradient(top,  #4b4b4b,  #2f2f2f); /* for firefox 3.6+ */
 background-image: -o-linear-gradient(#4b4b4b, #2f2f2f); /* opera gradient */
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4b4b4b', endColorstr='#2f2f2f'); /* for IE7 */
 -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#4b4b4b, endColorstr=#2f2f2f)"; /* IE8 + */
.menu li:first-child.ui-state-active a:before,
.menu li:last-child.ui-state-active a:after {
.menu li a:after,
.menu li a:before {
 width: 20px;
 height: 20px;
 -webkit-border-radius: 10px;
 -moz-border-radius:    10px;
 border-radius:         10px;
 background: #fff;
 z-index: 2;
.menu li a:before {
 left: -20px;
.menu li a:after {
 right: -20px;
/* .ui-state-active tab */
.menu .ui-state-active {
 z-index: 3;
.menu .ui-state-active a {
 background: -webkit-gradient(linear, left top, left bottom, from(#39B5E8), to(#0481B1)); /* for webkit browsers */
 background: -moz-linear-gradient(top,  #39B5E8,  #0481B1); /* for firefox 3.6+ */
 background-image: -o-linear-gradient(#39B5E8, #0481B1); /* opera gradient */
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#39B5E8', endColorstr='#0481B1'); /* for IE7 */
 -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#39B5E8, endColorstr=#0481B1)"; /* IE8 + */
.menu .ui-state-active a:after,
.menu .ui-state-active a:before {
 background: -webkit-gradient(linear, left top, left bottom, from(#3d3d3d), to(#2f2f2f)); /* for webkit browsers */
 background: -moz-linear-gradient(top,  #3d3d3d,  #2f2f2f); /* for firefox 3.6+ */
 background-image: -o-linear-gradient(#3d3d3d, #2f2f2f); /* opera gradient */
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d3d3d', endColorstr='#2f2f2f'); /* for IE7 */
 -ms-filter: "progid:DXImageTransform.Microsoft.gradient (GradientType=0, startColorstr=#3d3d3d, endColorstr=#2f2f2f)"; /* IE8 + */
.menu .ui-state-active:before,
.menu .ui-state-active:after {
 z-index: 1;
/* content */
.menu_content {
 margin:0 auto;
 padding:10px 30px;
 border-radius:15px 15px 15px 15px;
 -webkit-border-radius:15px 15px 15px 15px;
 -moz-border-radius:15px 15px 15px 15px;
 -khtml-border-radius:15px 15px 15px 15px;
 box-shadow:0px 2px 3px #000;
.ui-tabs-hide {

This is the entire CSS. Not to worry it’s not that hard.
What I used so I can build this menu is :before and :after pseudo-elements pseudo-elements.
Ok now I know that I should brake the code piece by piece. But this time I wont do it.
But if you need help or you want to ask me something about this tutorial just feel free to add a comment and I’ll try to give you as much details as I can.

Let’s move forward with the final part of the tutorial the JQuery script.

Finally: the javascript

$(function() {

If you have worked with JQuery UI – Tabs you will probably know that this is the default functionality. In conclusion there is not much about this piece of code that I should explain.
You can find more details here.

IE8 and IE7 – they look good but doesn’t create the round out corners

Here is the standalone page.

One thought on “Create a Fancy Menu with CSS3 and JQuery tabs

  1. I’m impressed, I must say. Seldom do I encounter a blog that’s both equally educative and
    interesting, and without a doubt, you’ve hit the nail
    on the head. The problem is something too few men and women are speaking intelligently about.
    I’m very happy that I found this in my hunt for something relating to this.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.