How to Build a Kick-Butt CSS3 Mega Drop-Down Menu

How to Build a Kick-Butt CSS3 Mega Drop-Down Menu

Tutorial Details
  • Topic: HTML / CSS3
  • Difficulty: Moderate
  • Estimated Completion Time: 30 min

Final Product What You'll Be Creating

This entry is part 16 of 16 in the CSS3 Mastery Session
« Previous

Often used on e-commerce or large scale websites, mega menus are becoming more and more popular, as they offer an effective solution to displaying a lot of content while keeping a clean layout. In this tutorial, we’ll learn how to build a cross-browser, awesome CSS-only drop-down mega menu, using nice CSS3 features.


Step 1: Building the Navigation Bar

Let’s begin with a basic menu, built with an unordered list and some basic CSS styling.

<ul id="menu">
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Portfolio</a></li>
    <li><a href="#">Contact</a></li>
</ul>

Creating the Menu Container

We’ll now apply some basic CSS styling. For the menu container, we define a fixed width that we center by setting the left and right margins to “auto”.

#menu {
	list-style:none;
	width:940px;
	margin:30px auto 0px auto;
	height:43px;
	padding:0px 20px 0px 20px;
}

Now, let’s see how we can improve it with some CSS3 features. We need to use different syntaxes for Webkit-based browsers (like Safari) and for Mozilla-based browsers (like Firefox).

For rounded corners, the syntax will be :

-moz-border-radius: 10px
-webkit-border-radius: 10px;
border-radius: 10px;

For the background, we’ll use gradients and a fallback color for older browsers. To keep consistency when choosing colors, there is an awesome tool called Facade that helps you find lighter and darker tones of a basic color.

background: #014464;
background: -moz-linear-gradient(top, #0272a7, #013953);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));

The first line applies a simple background color (for older browsers); the second and third lines create a gradient from the top to the bottom using two colors : #0272a7 and #013953.

We can now add a darker border and polish the design with a “fake” inset border created with the “box-shadow” feature. The syntax is the same for all compatible browsers: the first value is the horizontal offset, the second one is the vertical offset, the third one is the blur radius (a small value makes it sharper; it will be 1 pixel in our example). We set all offsets to 0 so the blur value will create a uniform light border :

-moz-box-shadow:inset 0px 0px 1px #edf9ff;
-webkit-box-shadow:inset 0px 0px 1px #edf9ff;
box-shadow:inset 0px 0px 1px #edf9ff;

Here’s the final CSS code for the #menu container :

#menu {
	list-style:none;
	width:940px;
	margin:30px auto 0px auto;
	height:43px;
	padding:0px 20px 0px 20px;

	/* Rounded Corners */
	
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px;

	/* Background color and gradients */
	
	background: #014464;
	background: -moz-linear-gradient(top, #0272a7, #013953);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
	
	/* Borders */
	
	border: 1px solid #002232;

	-moz-box-shadow:inset 0px 0px 1px #edf9ff;
	-webkit-box-shadow:inset 0px 0px 1px #edf9ff;
	box-shadow:inset 0px 0px 1px #edf9ff;
}

Styling Menu Items

We will begin with all menu items aligned to the left and space them with a margin-right (the padding will be necessary for the hover state) :

#menu li {
	float:left;
	display:block;
	text-align:center;
	position:relative;
	padding: 4px 10px 4px 10px;
	margin-right:30px;
	margin-top:7px;
	border:none;
}

For the hover state and the drop down, I have chosen a grey color scheme for the background.

The fallback color will be a light grey (#F4F4F4) and the gradient will be applied from the top (#F4F4F4) to the bottom (#EEEEEE). Rounded corners will be applied only on top corners as we’ll have the drop down sticking right under the menu items.

background: #F4F4F4;
background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));

The left and right padding is slightly smaller here because we have a border of 1 pixel appearing on hover. If we keep the same padding, menu items will be pushed two pixels on the right because of the left and right borders added on mouse hover. To avoid that, we’ll remove 1 pixel of padding on both sides, so we have 9 pixels instead of 10.

border: 1px solid #777777;
padding: 4px 9px 4px 9px;

Then, we add rounded corners to the top only so the drop down will stick perfectly under the parent menu item :

-moz-border-radius: 5px 5px 0px 0px;
-webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;

Here is the final CSS for the menu items on hover :

#menu li:hover {
	border: 1px solid #777777;
	padding: 4px 9px 4px 9px;
	
	/* Background color and gradients */
	
	background: #F4F4F4;
	background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
	
	/* Rounded corners */
	
	-moz-border-radius: 5px 5px 0px 0px;
	-webkit-border-radius: 5px 5px 0px 0px;
	border-radius: 5px 5px 0px 0px;
}

For the links, we’ll apply a nice text shadow using a simple syntax : the first and second values are horizontal and vertical offsets for the shadow (1 pixel in our example), the third one is the blur (1 pixel too) and then we have the (black) color :

text-shadow: 1px 1px 1px #000;

Here is the final CSS for the links :

#menu li a {
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px; 
	color: #EEEEEE;
	display:block;
	outline:0;
	text-decoration:none;
	text-shadow: 1px 1px 1px #000;
}

On mouse hover, as the background is grey, we’ll use a darker color (#161616) for the links and the white color for the text shadow :

#menu li:hover a {
	color:#161616;
	text-shadow: 1px 1px 1px #FFFFFF;
}

Finally, we need a way to indicate if there’s a drop down or not by using a simple arrow image as background, it will be positioned on the right using padding and the top margin will align to it properly. On hover this top margin will be set to 7 pixels instead of 8 as we have an additional border appearing on mouse hover (otherwise, the arrow would be pushed 1 pixel down on hover) :

#menu li .drop {
	padding-right:21px;
	background:url("img/drop.png") no-repeat right 8px;
}
#menu li:hover .drop {
	background:url("img/drop.png") no-repeat right 7px;
}

Here is our final code for the menu container and links; only the “home” item doesn’t have any drop down content for now :

<ul id="menu">
	<li><a href="#">Home</a></li>
	<li><a href="#" class="drop">About</a></li>
	<li><a href="#" class="drop">Services</a></li>
	<li><a href="#" class="drop">Portfolio</a></li>
	<li><a href="#" class="drop">Contact</a></li>
</ul>
#menu {
	list-style:none;
	width:940px;
	margin:30px auto 0px auto;
	height:43px;
	padding:0px 20px 0px 20px;

	/* Rounded Corners */
	
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px;

	/* Background color and gradients */
	
	background: #014464;
	background: -moz-linear-gradient(top, #0272a7, #013953);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
	
	/* Borders */
	
	border: 1px solid #002232;

	-moz-box-shadow:inset 0px 0px 1px #edf9ff;
	-webkit-box-shadow:inset 0px 0px 1px #edf9ff;
	box-shadow:inset 0px 0px 1px #edf9ff;
}

#menu li {
	float:left;
	display:block;
	text-align:center;
	position:relative;
	padding: 4px 10px 4px 10px;
	margin-right:30px;
	margin-top:7px;
	border:none;
}

#menu li:hover {
	border: 1px solid #777777;
	padding: 4px 9px 4px 9px;
	
	/* Background color and gradients */
	
	background: #F4F4F4;
	background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
	
	/* Rounded corners */
	
	-moz-border-radius: 5px 5px 0px 0px;
	-webkit-border-radius: 5px 5px 0px 0px;
	border-radius: 5px 5px 0px 0px;
}

#menu li a {
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px; 
	color: #EEEEEE;
	display:block;
	outline:0;
	text-decoration:none;
	text-shadow: 1px 1px 1px #000;
}

#menu li:hover a {
	color:#161616;
	text-shadow: 1px 1px 1px #FFFFFF;
}
#menu li .drop {
	padding-right:21px;
	background:url("img/drop.png") no-repeat right 8px;
}
#menu li:hover .drop {
	background:url("img/drop.png") no-repeat right 7px;
}

And the result is :

Building a CSS3 Mega Drop Down Menu

Step 2: Coding the Drop Down

A “classic” drop down menu usually contains lists nested within parent list items and looks like:

<ul id="menu">
	<li><a href="#">Item 1</a><
		<ul>
			<li><a href="#">Subitem 1</a></li>
			<li><a href="#">Subitem 2</a></li>
			<li><a href="#">Subitem 3</a></li>
		</ul>
	</li>
	<li><a href="#">Item 2</a><
		<ul>
			<li><a href="#">Subitem 1</a></li>
			<li><a href="#">Subitem 2</a></li>
		</ul>
	</li>
</ul>

General Structure

For our Mega Menu, instead of nested lists, we’ll simply use standard DIVs, which will work like any nested list :

<ul id="menu">
	<li><a href="#">Item 1</a>
		<div>
		Drop down Content
		<div>
	</li>
	<li><a href="#">Item 2</a>
		<div>
		Drop down Content
		<div>
	</li>
</ul>

This will be the basic structure for the drop down. The idea behind it is to be able to include any kind of content, such as paragraphs, images, custom lists or a contact form, organized into columns.

Drop Down Containers

Containers with different sizes will hold the entire drop down content. I’ve chosen the tag names according to the number of columns they will contain.

To hide the drop downs, we’ll use absolute positioning with a negative left margin :

position:absolute;
left:-999em;

The background fallback color is the same as the one used for the menu items. Modern browsers will display a gradient starting with #EEEEEE at the top (to match the parent menu item gradient) and ending with #BBBBBB at the bottom:

background:#F4F4F4;
background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));

We’ll again use rounded corners, except for the top left one :

-moz-border-radius: 0px 5px 5px 5px;
-webkit-border-radius: 0px 5px 5px 5px;
border-radius: 0px 5px 5px 5px;
.dropdown_1column, 
.dropdown_2columns, 
.dropdown_3columns, 
.dropdown_4columns,
.dropdown_5columns {
	margin:4px auto;
	position:absolute;
	left:-999em; /* Hides the drop down */
	text-align:left;
	padding:10px 5px 10px 5px;
	border:1px solid #777777;
	border-top:none;
	
	/* Gradient background */
	background:#F4F4F4;
	background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));

	/* Rounded Corners */
	-moz-border-radius: 0px 5px 5px 5px;
	-webkit-border-radius: 0px 5px 5px 5px;
	border-radius: 0px 5px 5px 5px;
}

To illustrate this, let’s see how it would look if we hadn’t paid attention to detail:

Building a CSS3 Mega Drop Down Menu

Now here is our example:

Building a CSS3 Mega Drop Down Menu

As you can see, the drop down sticks nicely to its parent menu item.

In order to have a perfect drop down container, we need to specify the width for each one :

.dropdown_1column {width: 140px;}
.dropdown_2columns {width: 280px;}
.dropdown_3columns {width: 420px;}
.dropdown_4columns {width: 560px;}
.dropdown_5columns {width: 700px;}

And to show the drop downs on mouse hover, we’ll simply use :

#menu li:hover .dropdown_1column, 
#menu li:hover .dropdown_2columns, 
#menu li:hover .dropdown_3columns,
#menu li:hover .dropdown_4columns,
#menu li:hover .dropdown_5columns {
	left:-1px;top:auto;
}

Using the Drop Down Containers

Our classes are ready to be included in our menu. We’ll use each one of them starting from the 5-column, layout to the single column drop down :

<ul id="menu">
	<li><a href="#">Home</a></li>
	<li><a href="#" class="drop">5 Columns</a>
		<div class="dropdown_5columns">
		<p>5 Columns content</p>
		</div>
	</li>
	<li><a href="#" class="drop">4 Columns</a>
		<div class="dropdown_4columns">
		<p>4 Columns content</p>
		</div>
	</li>
	<li><a href="#" class="drop">3 Columns</a>
		<div class="dropdown_3columns">
		<p>3 Columns content</p>
		</div>
	</li>
	<li><a href="#" class="drop">2 Columns</a>
		<div class="dropdown_2columns">
		<p>2 Columns content</p>
		</div>
	</li>
	<li><a href="#" class="drop">1 Column</a>
		<div class="dropdown_1column">
		<p>1 Column content</p>
		</div>
	</li>
</ul>

Here is a preview of the code above :

Building a CSS3 Mega Drop Down Menu

Step 3: Creating the Drop Down Container Columns

Now that we have the containers ready, we’ll create columns of increasing sizes, following the principles of the 960 grid system.

.col_1,
.col_2,
.col_3,
.col_4,
.col_5 {
	display:inline;
	float: left;
	position: relative;
	margin-left: 5px;
	margin-right: 5px;
}
.col_1 {width:130px;}
.col_2 {width:270px;}
.col_3 {width:410px;}
.col_4 {width:550px;}
.col_5 {width:690px;}

Using Columns

Here is an example of a drop down containing several columns. In this example, we have different combinations using all kinds of columns :

<ul id="menu">
	<li><a href="#" class="drop">5 Columns</a>
		<div class="dropdown_5columns">
			<div class="col_5">
			<p>This is a 5 Columns content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_4">
			<p>This is a 4 Columns content</p>
			</div>
			<div class="col_1">
			<p>This is a 1 Column content</p>
			</div>
			<div class="col_3">
			<p>This is a 3 Columns content</p>
			</div>
			<div class="col_2">
			<p>This is a 2 Columns content</p>
			</div>
		</div>
	</li>
</ul>

Code preview :

Building a CSS3 Mega Drop Down Menu

Step 4: Aligning to the Right

Now, let’s see how we can align our menu and the drop down content to the right edge of the navigation bar; not only the menu item, but the drop down container should also be changed.

To accomplish this, we’ll add a new class called .menu_right to the parent list item, so we reset the right margin and float it to the right :

#menu .menu_right {
	float:right;
	margin-right:0px;
}

Next, let’s see the drop down. In the previous CSS code, rounded corners were applied to all corners except the left-top one to, in order to match the background of the parent menu item. Now we want this drop down to stick to the right edge of the parent menu item. So, we’ll overwrite the border-radius values with a new class called .align_right, and set the top-right corner to 0.

#menu li .align_right {
	/* Rounded Corners */
	-moz-border-radius: 5px 0px 5px 5px;
	-webkit-border-radius: 5px 0px 5px 5px;
	border-radius: 5px 0px 5px 5px;
}

Last but not least, we want to make the drop down appear on the right; so we’ll use our new class and reset the left value, then make it stick to the right :

#menu li:hover .align_right {
	left:auto;
	right:-1px;
	top:auto;
}

Now it’s ready to be used in the menu :

<li class="menu_right"><a href="#" class="drop">Right</a>
	<div class="dropdown_1column align_right">
		<div class="col_1">
		<p>This is a 1 Column content</p>
		</div>
	</div>
</li>

And a small preview of the code above :

Building a CSS3 Mega Drop Down Menu

Step 5: Adding and Styling Content

Now that we have the whole structure ready, we can add as much content as we want: text, lists, images, etc.

General Stylings

Let’s begin with some basic styling for paragraphs and headings :

#menu p, #menu h2, #menu h3, #menu ul li {
	font-family:Arial, Helvetica, sans-serif;
	line-height:21px;
	font-size:12px;
	text-align:left;
	text-shadow: 1px 1px 1px #FFFFFF;
}
#menu h2 {
	font-size:21px;
	font-weight:400;
	letter-spacing:-1px;
	margin:7px 0 14px 0;
	padding-bottom:14px;
	border-bottom:1px solid #666666;
}
#menu h3 {
	font-size:14px;
	margin:7px 0 14px 0;
	padding-bottom:7px;
	border-bottom:1px solid #888888;
}
#menu p {
	line-height:18px;
	margin:0 0 10px 0;
}
.strong {
	font-weight:bold;
}
.italic {
	font-style:italic;
}

We can apply a nice blue color to the links within the drop down :

#menu li:hover div a {
	font-size:12px;
	color:#015b86;
}
#menu li:hover div a:hover {
	color:#029feb;
}

Lists Stylings

Let’s revamp our lists; we have to reset some styling such as the background color or the borders which are used in the navigation bar :

#menu li ul {
	list-style:none;
	padding:0;
	margin:0 0 12px 0;
}
#menu li ul li {
	font-size:12px;
	line-height:24px;
	position:relative;
	text-shadow: 1px 1px 1px #ffffff;
	padding:0;
	margin:0;
	float:none;
	text-align:left;
	width:130px;
}
#menu li ul li:hover {
	background:none;
	border:none;
	padding:0;
	margin:0;
}

Styling Images

.imgshadow {
	background:#FFFFFF;
	padding:4px;
	border:1px solid #777777;
	margin-top:5px;
	-moz-box-shadow:0px 0px 5px #666666;
	-webkit-box-shadow:0px 0px 5px #666666;
	box-shadow:0px 0px 5px #666666;
}

And to create a paragraph with an image on the left :

.img_left {
	width:auto;
	float:left;
	margin:5px 15px 5px 5px;
}

Text Boxes

To highlight some content, here is an example of a dark box with rounded corners and a subtle inset shadow :

#menu li .black_box {
	background-color:#333333;
	color: #eeeeee;
	text-shadow: 1px 1px 1px #000;
	padding:4px 6px 4px 6px;

	/* Rounded Corners */
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;

	/* Shadow */
	-webkit-box-shadow:inset 0 0 3px #000000;
	-moz-box-shadow:inset 0 0 3px #000000;
	box-shadow:inset 0 0 3px #000000;
}

Restylings Lists

And to finish, here’s another way to style your lists using, again, some CSS3 :

#menu li .greybox li {
	background:#F4F4F4;
	border:1px solid #bbbbbb;
	margin:0px 0px 4px 0px;
	padding:4px 6px 4px 6px;
	width:116px;

	/* Rounded Corners */
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
}
#menu li .greybox li:hover {
	background:#ffffff;
	border:1px solid #aaaaaa;
	padding:4px 6px 4px 6px;
	margin:0px 0px 4px 0px;
}

Step 6: Handling Browser Compatibility and IE6

All browsers handle hover on non-anchor tags . . . except Internet Explorer 6; so our Mega Menu is still not working with this old browser. We can fix this problem thanks to a behavior file that will add this functionality. You can find it here, and use conditional comments to target IE6 only; more explanations can be found via this article from CSS-Tricks.

To target IE6, we’ll use the following code :

<!--[if IE 6]>
<style>
body {behavior: url("csshover3.htc");}
</style>
<![endif]-->

I’ve used a few PNG files in this tutorial, and, as everyone knows, IE6 doesn’t support transparency so we have different solutions :

  • Convert them to GIF or PNG-8 format
  • Use a script
  • Set a background color other than the default grey with TweakPNG for example

I’ll let you choose the one that fits to your needs. Now, let’s review a full working example.


Final Example

HTML Part

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="menu.css" type="text/css" media="screen" />

<title>Mega Drop Down Menu</title>
<!--[if IE 6]>
<style>
body {behavior: url("csshover3.htc");}
#menu li .drop {background:url("img/drop.gif") no-repeat right 8px; 
</style>
<![endif]-->

</head>

<body>

<ul id="menu">
    
    <li><a href="#" class="drop">Home</a><!-- Begin Home Item -->
    
        <div class="dropdown_2columns"><!-- Begin 2 columns container -->
    
            <div class="col_2">
                <h2>Welcome !</h2>
            </div>
    
            <div class="col_2">
                <p>Hi and welcome here ! This is a showcase of the possibilities of this awesome Mega Drop Down Menu.</p>             
                <p>This item comes with a large range of prepared typographic stylings such as headings, lists, etc.</p>             
            </div>
    
            <div class="col_2">
                <h2>Cross Browser Support</h2>
            </div>
            
            <div class="col_1">
                <img src="img/browsers.png" width="125" height="48" alt="" />
            </div>
            
            <div class="col_1">
                <p>This mega menu has been tested in all major browsers.</p>
            </div>
          
        </div><!-- End 2 columns container -->
    
    </li><!-- End Home Item -->

    <li><a href="#" class="drop">5 Columns</a><!-- Begin 5 columns Item -->
    
        <div class="dropdown_5columns"><!-- Begin 5 columns container -->
        
            <div class="col_5">
                <h2>This is an example of a large container with 5 columns</h2>
            </div>
            
            <div class="col_1">
                <p class="black_box">This is a dark grey box text. Fusce in metus at enim porta lacinia vitae a arcu. Sed sed lacus nulla mollis porta quis.</p>
            </div>
            
            <div class="col_1">
                <p>Phasellus vitae sapien ac leo mollis porta quis sit amet nisi. Mauris hendrerit, metus cursus accumsan tincidunt.</p>
            </div>
            
            <div class="col_1">
                <p class="italic">This is a sample of an italic text. Consequat scelerisque. Fusce sed lectus at arcu mollis accumsan at nec nisi porta quis sit amet.</p>
            </div>
            
            <div class="col_1">
                <p>Curabitur euismod gravida ante nec commodo. Nunc dolor nulla, semper in ultricies vitae, vulputate porttitor neque.</p>
            </div>
            
            <div class="col_1">
                <p class="strong">This is a sample of a bold text. Aliquam sodales nisi nec felis hendrerit ac eleifend lectus feugiat scelerisque.</p>
            </div>
        
            <div class="col_5">
                <h2>Here is some content with side images</h2>
            </div>
           
            <div class="col_3">
            
                <img src="img/01.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
                <p>Maecenas eget eros lorem, nec pellentesque lacus. Aenean dui orci, rhoncus sit amet tristique eu, tristique sed odio. Praesent ut interdum elit. Sed in sem mauris. Aenean a commodo mi. Praesent augue lacus.<a href="#">Read more...</a></p>
        
                <img src="img/02.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
                <p>Aliquam elementum felis quis felis consequat scelerisque. Fusce sed lectus at arcu mollis accumsan at nec nisi. Aliquam pretium mollis fringilla. Nunc in leo urna, eget varius metus. Aliquam sodales nisi.<a href="#">Read more...</a></p>
            
            </div>
            
            <div class="col_2">
            
                <p class="black_box">This is a black box, you can use it to highligh some content. Sed sed lacus nulla, et lacinia risus. Phasellus vitae sapien ac leo mollis porta quis sit amet nisi. Mauris hendrerit, metus cursus accumsan tincidunt.Quisque vestibulum nisi non nunc blandit placerat. Mauris facilisis, risus ut lobortis posuere, diam lacus congue lorem, ut condimentum ligula est vel orci. Donec interdum lacus at velit varius gravida. Nulla ipsum risus.</p>
            
            </div>
        
        </div><!-- End 5 columns container -->
    
    </li><!-- End 5 columns Item -->

    <li><a href="#" class="drop">4 Columns</a><!-- Begin 4 columns Item -->
    
        <div class="dropdown_4columns"><!-- Begin 4 columns container -->
        
            <div class="col_4">
                <h2>This is a heading title</h2>
            </div>
            
            <div class="col_1">
            
                <h3>Some Links</h3>
                <ul>
                    <li><a href="#">ThemeForest</a></li>
                    <li><a href="#">GraphicRiver</a></li>
                    <li><a href="#">ActiveDen</a></li>
                    <li><a href="#">VideoHive</a></li>
                    <li><a href="#">3DOcean</a></li>
                </ul>   
                 
            </div>
    
            <div class="col_1">
            
                <h3>Useful Links</h3>
                <ul>
                    <li><a href="#">NetTuts</a></li>
                    <li><a href="#">VectorTuts</a></li>
                    <li><a href="#">PsdTuts</a></li>
                    <li><a href="#">PhotoTuts</a></li>
                    <li><a href="#">ActiveTuts</a></li>
                </ul>   
                 
            </div>
    
            <div class="col_1">
            
                <h3>Other Stuff</h3>
                <ul>
                    <li><a href="#">FreelanceSwitch</a></li>
                    <li><a href="#">Creattica</a></li>
                    <li><a href="#">WorkAwesome</a></li>
                    <li><a href="#">Mac Apps</a></li>
                    <li><a href="#">Web Apps</a></li>
                </ul>   
                 
            </div>
    
            <div class="col_1">
            
                <h3>Misc</h3>
                <ul>
                    <li><a href="#">Design</a></li>
                    <li><a href="#">Logo</a></li>
                    <li><a href="#">Flash</a></li>
                    <li><a href="#">Illustration</a></li>
                    <li><a href="#">More...</a></li>
                </ul>   
                 
            </div>
            
        </div><!-- End 4 columns container -->
    
    </li><!-- End 4 columns Item -->

	<li class="menu_right"><a href="#" class="drop">1 Column</a>
    
		<div class="dropdown_1column align_right">
        
                <div class="col_1">
                
                    <ul class="simple">
                        <li><a href="#">FreelanceSwitch</a></li>
                        <li><a href="#">Creattica</a></li>
                        <li><a href="#">WorkAwesome</a></li>
                        <li><a href="#">Mac Apps</a></li>
                        <li><a href="#">Web Apps</a></li>
                        <li><a href="#">NetTuts</a></li>
                        <li><a href="#">VectorTuts</a></li>
                        <li><a href="#">PsdTuts</a></li>
                        <li><a href="#">PhotoTuts</a></li>
                        <li><a href="#">ActiveTuts</a></li>
                        <li><a href="#">Design</a></li>
                        <li><a href="#">Logo</a></li>
                        <li><a href="#">Flash</a></li>
                        <li><a href="#">Illustration</a></li>
                        <li><a href="#">More...</a></li>
                    </ul>   
                     
                </div>
                
		</div>
        
	</li>

    <li class="menu_right"><a href="#" class="drop">3 columns</a><!-- Begin 3 columns Item -->
    
        <div class="dropdown_3columns align_right"><!-- Begin 3 columns container -->
            
            <div class="col_3">
                <h2>Lists in Boxes</h2>
            </div>
            
            <div class="col_1">
    
                <ul class="greybox">
                    <li><a href="#">FreelanceSwitch</a></li>
                    <li><a href="#">Creattica</a></li>
                    <li><a href="#">WorkAwesome</a></li>
                    <li><a href="#">Mac Apps</a></li>
                    <li><a href="#">Web Apps</a></li>
                </ul>   
    
            </div>
            
            <div class="col_1">
    
                <ul class="greybox">
                    <li><a href="#">ThemeForest</a></li>
                    <li><a href="#">GraphicRiver</a></li>
                    <li><a href="#">ActiveDen</a></li>
                    <li><a href="#">VideoHive</a></li>
                    <li><a href="#">3DOcean</a></li>
                </ul>   
    
            </div>
            
            <div class="col_1">
    
                <ul class="greybox">
                    <li><a href="#">Design</a></li>
                    <li><a href="#">Logo</a></li>
                    <li><a href="#">Flash</a></li>
                    <li><a href="#">Illustration</a></li>
                    <li><a href="#">More...</a></li>
                </ul>   
    
            </div>
            
            <div class="col_3">
                <h2>Here are some image examples</h2>
            </div>
            
            <div class="col_3">
                <img src="img/02.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
                <p>Maecenas eget eros lorem, nec pellentesque lacus. Aenean dui orci, rhoncus sit amet tristique eu, tristique sed odio. Praesent ut interdum elit. Maecenas imperdiet, nibh vitae rutrum vulputate, lorem sem condimentum.<a href="#">Read more...</a></p>
    
                <img src="img/01.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
                <p>Aliquam elementum felis quis felis consequat scelerisque. Fusce sed lectus at arcu mollis accumsan at nec nisi. Aliquam pretium mollis fringilla. Vestibulum tempor facilisis malesuada. <a href="#">Read more...</a></p>
            </div>
        
        </div><!-- End 3 columns container -->
        
    </li><!-- End 3 columns Item -->
</ul>

</body>

</html>

CSS Part

body, ul, li {
	font-size:14px; 
	font-family:Arial, Helvetica, sans-serif;
	line-height:21px;
	text-align:left;
}

/* Navigation Bar */

#menu {
	list-style:none;
	width:940px;
	margin:30px auto 0px auto;
	height:43px;
	padding:0px 20px 0px 20px;

	/* Rounded Corners */
	
	-moz-border-radius: 10px;
	-webkit-border-radius: 10px;
	border-radius: 10px;

	/* Background color and gradients */
	
	background: #014464;
	background: -moz-linear-gradient(top, #0272a7, #013953);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
	
	/* Borders */
	
	border: 1px solid #002232;

	-moz-box-shadow:inset 0px 0px 1px #edf9ff;
	-webkit-box-shadow:inset 0px 0px 1px #edf9ff;
	box-shadow:inset 0px 0px 1px #edf9ff;
}

#menu li {
	float:left;
	text-align:center;
	position:relative;
	padding: 4px 10px 4px 10px;
	margin-right:30px;
	margin-top:7px;
	border:none;
}

#menu li:hover {
	border: 1px solid #777777;
	padding: 4px 9px 4px 9px;
	
	/* Background color and gradients */
	
	background: #F4F4F4;
	background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
	
	/* Rounded corners */
	
	-moz-border-radius: 5px 5px 0px 0px;
	-webkit-border-radius: 5px 5px 0px 0px;
	border-radius: 5px 5px 0px 0px;
}

#menu li a {
	font-family:Arial, Helvetica, sans-serif;
	font-size:14px; 
	color: #EEEEEE;
	display:block;
	outline:0;
	text-decoration:none;
	text-shadow: 1px 1px 1px #000;
}

#menu li:hover a {
	color:#161616;
	text-shadow: 1px 1px 1px #FFFFFF;
}
#menu li .drop {
	padding-right:21px;
	background:url("img/drop.png") no-repeat right 8px;
}
#menu li:hover .drop {
	background:url("img/drop.png") no-repeat right 7px;
}

/* Drop Down */

.dropdown_1column, 
.dropdown_2columns, 
.dropdown_3columns, 
.dropdown_4columns,
.dropdown_5columns {
	margin:4px auto;
	float:left;
	position:absolute;
	left:-999em; /* Hides the drop down */
	text-align:left;
	padding:10px 5px 10px 5px;
	border:1px solid #777777;
	border-top:none;
	
	/* Gradient background */
	background:#F4F4F4;
	background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));

	/* Rounded Corners */
	-moz-border-radius: 0px 5px 5px 5px;
	-webkit-border-radius: 0px 5px 5px 5px;
	border-radius: 0px 5px 5px 5px;
}

.dropdown_1column {width: 140px;}
.dropdown_2columns {width: 280px;}
.dropdown_3columns {width: 420px;}
.dropdown_4columns {width: 560px;}
.dropdown_5columns {width: 700px;}

#menu li:hover .dropdown_1column, 
#menu li:hover .dropdown_2columns, 
#menu li:hover .dropdown_3columns,
#menu li:hover .dropdown_4columns,
#menu li:hover .dropdown_5columns {
	left:-1px;
    top:auto;
}

/* Columns */

.col_1,
.col_2,
.col_3,
.col_4,
.col_5 {
	display:inline;
	float: left;
	position: relative;
	margin-left: 5px;
	margin-right: 5px;
}
.col_1 {width:130px;}
.col_2 {width:270px;}
.col_3 {width:410px;}
.col_4 {width:550px;}
.col_5 {width:690px;}

/* Right alignment */

#menu .menu_right {
	float:right;
	margin-right:0px;
}
#menu li .align_right {
	/* Rounded Corners */
	-moz-border-radius: 5px 0px 5px 5px;
    -webkit-border-radius: 5px 0px 5px 5px;
    border-radius: 5px 0px 5px 5px;
}
#menu li:hover .align_right {
	left:auto;
	right:-1px;
	top:auto;
}

/* Drop Down Content Stylings */

#menu p, #menu h2, #menu h3, #menu ul li {
	font-family:Arial, Helvetica, sans-serif;
	line-height:21px;
	font-size:12px;
	text-align:left;
	text-shadow: 1px 1px 1px #FFFFFF;
}
#menu h2 {
	font-size:21px;
	font-weight:400;
	letter-spacing:-1px;
	margin:7px 0 14px 0;
	padding-bottom:14px;
	border-bottom:1px solid #666666;
}
#menu h3 {
	font-size:14px;
	margin:7px 0 14px 0;
	padding-bottom:7px;
	border-bottom:1px solid #888888;
}
#menu p {
	line-height:18px;
	margin:0 0 10px 0;
}

#menu li:hover div a {
	font-size:12px;
	color:#015b86;
}
#menu li:hover div a:hover {
	color:#029feb;
}
.strong {
	font-weight:bold;
}
.italic {
	font-style:italic;
}
.imgshadow {
	background:#FFFFFF;
	padding:4px;
	border:1px solid #777777;
	margin-top:5px;
	-moz-box-shadow:0px 0px 5px #666666;
	-webkit-box-shadow:0px 0px 5px #666666;
	box-shadow:0px 0px 5px #666666;
}
.img_left { /* Image sticks to the left */
	width:auto;
	float:left;
	margin:5px 15px 5px 5px;
}
#menu li .black_box {
	background-color:#333333;
	color: #eeeeee;
	text-shadow: 1px 1px 1px #000;
	padding:4px 6px 4px 6px;

	/* Rounded Corners */
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;

	/* Shadow */
	-webkit-box-shadow:inset 0 0 3px #000000;
	-moz-box-shadow:inset 0 0 3px #000000;
	box-shadow:inset 0 0 3px #000000;
}
#menu li ul {
	list-style:none;
	padding:0;
	margin:0 0 12px 0;
}
#menu li ul li {
	font-size:12px;
	line-height:24px;
	position:relative;
	text-shadow: 1px 1px 1px #ffffff;
	padding:0;
	margin:0;
	float:none;
	text-align:left;
	width:130px;
}
#menu li ul li:hover {
	background:none;
	border:none;
	padding:0;
	margin:0;
}
#menu li .greybox li {
	background:#F4F4F4;
	border:1px solid #bbbbbb;
	margin:0px 0px 4px 0px;
	padding:4px 6px 4px 6px;
	width:116px;

	/* Rounded Corners */
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
}
#menu li .greybox li:hover {
	background:#ffffff;
	border:1px solid #aaaaaa;
	padding:4px 6px 4px 6px;
	margin:0px 0px 4px 0px;
}

Interesting and Relevant Links


Conclusion

I hope you’ve enjoyed this tutorial on creating mega menus. Thanks for following along!

Guillaume Marty is Pixelworkshop on Codecanyon
Tags: CSScss3
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Greg

    This is really great, thank you! Do you know how to make the submenus “accessible” via keyboard functions? I’m trying to make the submenu appear as you tab through the page…with the current html/css, it is not possible.

    Thank you.

  • http://www.texascomunity.com alisultan

    mantap bang blognya langsung bisa d download (y)

  • http://about.me/lkravi lkravi

    Perfect ! Thank you for the tutorial !

  • http://www.facebook.com/Creative.We Creative.We

    I just have a question… how do I transfer this or use this if I am using iWeb and RapidWeaver :( Please help. I’m just doing this and I have only self-taught. If you would oblige, thank you in advance.

  • Greg

    Has anybody figured out how to make the submenu’s 508 accessible? I need the submenu’s to open when tabbing through and hitting enter. So far, I’ve been unsuccesful. Thanks.

  • http://moticont.com Action Jackson

    Can anyone tell me how to add a delay to the drop down menu?

    • Giles

      Unfortunately, since this is a css only menu – there is no handle to attach hoverintent to slow the menu onmouseover.

      Someone would have to re-write the code to be called via javascript rather than css.

      Happy to be corrected as this menu with hoverintent would be perfect.

  • kev

    this looks fantastic and i would like to use it, however i am using nopcommerce ecommerce site so how could i achieve this ?

  • Joe

    This is beautiful! You are a pro.

    Thanks!

  • SustainableOn

    Installed on SharePoint 2010 custom pages. Mega Drop Down code setup on a custom V4.master file.

    I have an issue when users go to print a pop-up screen like InfoPath, the drop down menu is showing up over the pop-up in the print view only. The list is not present on the actual screen just shows up when you go to print the form. The menu shows up in list format similar to a bulleted item list. IE 9 shows it over the form, Chrome version 20… only shows the list items in the header area of the form and pushes the rest of the list behind the infopath form.

    I’m guessing this has to do with Z-Index settings as I had the common issue of the drop down falling behind the main area of the page. I’m curious as to why it shows up when printing and not when displayed in the standard view.

  • May Marino

    This is really cool and easy to follow. Thanks for the great tutorial. Keep up the good work.

    100 thumbs up :D

  • Rufus

    This is perfect! just what I was looking for. Thanks!

  • http://www.lingua-franka.com Pepinho

    A very skillful way to use “simple” to create “complex”. Congratulations! Your menu really kicks ass.

  • Michelle

    Hi, I’m new to this, but I tried to morph together http://azadcreative.com/2009/03/bulletproof-css-sliding-doors/ with this drop down menu. So when someone clicks the top tab, it will select the top tab and produce a drop down menu on hover.

    So now, my navigation is set to 300px with no background. The drop downs appear on hover, but my content starts 300px after my menu bar.

    I fixed that by deleting position:relative. That worked in the sense that my menu bar is right above my content. However, I can’t click on any links that are within the top 300px of my content. Does anyone know how to fix this?
    I tried setting z-index to 9999 to no avail.

    Thanks!

    • MIchelle

      Oops, I meant “I fixed that be deleting float:left”

  • Josh

    Trying to sue this menu and it keeps hiding itself behind a video element on my page. Added z-index to both elements, but didn’t help with the ordering of the two elements. How can I get the menu to show above the video element. (only happens in IE8)

    • Clint

      This can’t be fixed with z-index. You’ll likely need to add ‘wmode=transparent’ to your video embed. Google that for more.

  • Kayleigh

    Is this free to use for my companys website?

  • Mario

    Hello, I used this menu on my blog along with a slide of images, but the slide is in front and not behind the menu.
    How do I fix it?

    • http://wpbeijing wpbeijing

      I had the same problem when i built mine, took me so long and was very frustrating.
      The answer ended up being quite simple, I added a z index and et Voila!
      But.
      Mine is NOT the same as this model, basic idea is the same so you may just have to experiment a bit.
      But don’t give up, z index is he key, you just need to find the right place for it in your code.
      Hope this helps

  • Dan

    That’s all fine and dandy, but does it blend? Erm.. i mean, it appears to be difficult to generate this kind of markup dynamically.

  • http://www.gdisinc.com Frank G.

    WOW… WOW!! Final a nice and easy to follow tutorial. I am new to css in general was very helpful thanks to your taking the extra time and explain all the areas of code and just your caring way of presenting things and not just say “Hey… here’s a css3 menu enjoy!” which we see all to much these days. It’s nice to see you got out of your way and take the time to help newbies like me understand what’s going on. I thank you for your hard work!! Thank you very much keep the tutorials coming :D

  • http://www.wpbeijing.com wpbeijing

    This is great,
    I made a sort of mega drop down on my site, but sadly it fails in the kick bottom department!
    I think I still want to keep my basic set up, I sweated blood over it as I am NOT even a designers rear end, but I will look at how I can breathe some life into it from this model.
    Again, Wow!
    Thank you so much for enlightenment and inspiration, I can take my rope noose down now!

  • http://www.gdisinc.com Frank G.

    Been playing around with your menu and I love it!!! But I do have a question. I have a 5 Column in the middle of the menu with a menu width of 960. However when I rollover I noticed that the menu runs off the screen. Could you suggested something to correct that? Thanks again!!!

    • http://www.gdisinc.com Frank G.

      Also is there a way to create a button that doesn’t have a drop down box. Just a plain old button. I notice when I don’t put a drop down attached to it then the bottom hover is short to reach the bottom of the menu? Could you provide me any suggestions for this?

      Thanks again!!

    • Clint

      The menu has an class called ‘align_right’ for just this purpose. Use it on any menu that gets too wide and runs off the screen:

      As far as your 2nd question below, I created a class called “single” which simple applies the border radius all the way around:

      #menu > li.single:hover {
      border-radius: 5px;
      }

      • Clint

        Oops. The commenting mechanism filtered my div example. Substitute angle braces for curly:

        {div class=”dropdown_3columns align_right”} … {/div}

  • Marcus

    Looks great! Question from ma as a newbie: so you don’t need any javasript for this? Is it also possible to let all submenues start absolute left (directly underneath “home”) and have a 100% width?

    Best regards,
    Marcus

  • sahar

    this is realy great.!!
    thanks very much…

  • http://mytechservices.info/pc/index.html Jeff

    By Far the Best CSS3 menu i have seen!

  • raja

    it is not working in ie6 please tell me very urgent………………

    • Jahan

      Hi Raja.

      If you understand it, please tell me about it. Thanks a lot.

      email: s.r.alem@gmail.com

  • http://irsah.com irsah

    WOW. Thanks for the details. Easy, straight forward and well explained. Thanks a lot. A few mods though for IE6, but at least you started the ball rolling. But again what the heck. hope people upgrade their browesrs (and PC too) so, won’t bother that much. Bookmarked and well done.

  • sgot

    This is just perfect!
    But i’d like to raise up an issue i experienced in building this and other dropdown menus.
    As you maybe noticed, there’s no top border on the dropdowns. In this case is barely recognizable because of the main menu bar background.
    But what if i wanted to set a top border and put it behind the tab? To better explain, i want to obtain the light gray outline all around the tab AND the dropdown, just like in the following image.
    http://media.smashingmagazine.com/images/drop-down-menus/macstorm.gif

    I tried with z-index also, but it seems it won’t work.

    Anyways this tutorial is amazing, clean and well explained. My compliments ;)

  • Kodio

    Hi! Thanks, good menu! How to make the menu open after clicking?

  • http://www.astrasuite.com Joe

    Thank you very much, it is kickbutt !

    Now being used at our website http://www.astrasuite.com. We will fine tune it later, but it first attempt and it is already running beautiful.

    I just added a z-index so it won’t get overlapped in some of our pages which has another menu below it.

    Thanks again …

  • Dwight

    Hi, this menu is excellent, however I have a small problem.

    When I create a top menu element, it seems to create a page break.

    So for example, I want to have :

    My Text ……

    However, the seems to take up the whole line, so it appears as:

    My Text …..

    Also, the menu element is creates white space above and below – I’m trying for less space utilization – more snug fitting, and also the ability to embed the menu object in natural text without causing a line or page break.

    Any ideas?

  • serena

    Great tutorial! Thanks!!

  • Philip Bolt

    Has anyone been able to get a submenu in this? I know it is available in the latest purchase version, but would like to try it out first.

  • sourabh

    Is there any plugin for wordpress for this kind of menu?????

  • http://aircraftrecognition.co.uk Ryan

    This menu is fantastic, just what I was looking for!

    Only problem is that it won’t display over google ads/flash or some of my css images.

    Is there a fix for this to get it to display on top of these?

    Thanks!

  • Mcmwhfy

    This menu is awesome but I want to customize in order to use display:none; and display:block; on hoover. Is not really ok to use positioning and left:-999em. Any help?

    • Henk Schouten

      I agree with Mcmwhfy. Did you get it to work without the left:-999em ??

      • Ron

        try:

        #menu li .dropdown_1column {
        margin: 13px auto;
        position:absolute;
        display:none;
        text-align:left;
        paddin:10px 5px;
        border:1px solid #777777;
        border-top:none;

        }
        #menu li:hover .dropdown_1column {
        display:block !important;
        width:126px;
        height:125px;
        top:auto;
        }

  • Diego CRuz

    I have a problem with my menu when you insert it into my web page, the menu is behind the content, how I can solve this problem Thanks

  • Richa

    This menu drop down list example is very helpful for me……. thanks

  • Mahesh Chavan

    very nice website contains all types of Menus….
    very interesting web site….
    It should have another web development tools…

    Thank You…

  • Louis

    I downloaded your demo and find it will serve my purpose. How ever. Is there away to make it vertical and not horizontal?

  • bridgemanusa

    First off, this menu and tutorial is awesome! Thanks so much for putting the effort into this and sharing it.

    Question: I am struggling with a few tweaks to this menu:

    1) Aligning dropdown div to be on center (rather than left or right) to it’s parent
    2) Assigning the arrow (flipped) image to be above the top border (pointing at the parent) – Whenever I try this it disappears.

    Any advise is greatly appreciated, and thanks again!

  • http://girlcalledpete.wordpress.com Pete McPhearson

    This is brilliant :)
    A great menu – and I’ve learned a lot about handling css just from reading through this and playing about with the css code you’ve provided :)
    Thanks :)

  • Dan The Man

    Hi guys
    great tutorial!!!
    is there any way to animate the dropdown of the menu and make it slowly appearing instead of just popping out?

  • Jay

    Does this work with IE9 on windows 7?
    All I see is a white box with drop down arrows. No background colour and hovering does nothing. Works perfctly for me in chrome though.

    • http://www.facebook.com/clint.buhs Clint Buhs

      It works very well in IE9, and with a little CSS3 PIE, it looks great in IE8, too.

      Has anyone applied transitions to this structure? I’d love to see a jQuery implementation to soften the dropdown effect.

    • CrazyBug

      im facing the same issues

      • LC

        Me too. It works fine on every other browser. Can someone help with the IE9 issue? I am using the code exactly as is from the tutorial.

      • http://www.facebook.com/people/Christian-Tintin-Johansson/562803246 Christian Tintin Johansson

        It works in IE 10 but for me it doesn´t work in IE 9 on either of my computers, and windows 7 of course.

  • Lee

    What is the difference between the Mega Menu complete set, Mega Menu Drop-down and Menu Menu Reloaded? The complete set is $1 cheaper than the Mega Menu drop-down which makes me think they are not the same products?

  • Yo

    thank you dude!

  • mn9or

    Love it :D

  • Valentin Secosan

    you are good, no javascript only css – this is what I need

  • DaWebmaster

    Awesome tutorial !

  • Francisco

    This is great and thorough! Just what I needed for my school project.

  • Steve M – www.bvgasa.org

    Excellent job here, thank you! I just put it up on my site. I have found some issues but am hoping to leave it up and work through them.
    #1 – Seems like this script carries a heavy work load. When using a mobile device, other moving parts, like a crawling picture array I use, slow way down. Can this be adjusted?
    #2 – I often use a small text scroller to show various messages but the menu drop down containers hide behind it. I tried using an opaque setting on the menu but didn’t work. I ended up removing the scroller. Can you help with this one?
    #3 – My home page is in 3 columns but the menu is so big it sits across most of it. I would like to move it to the right instead of centered and then deduce the margins between the menu li items to make it smaller.

    I guess that’s enough for now. Please don’t take this the wrong way because I love the menu! Best I have had and really want to keep it!

    Thanks

    • Steve M – www.bvgasa.org

      I was able to resolve the #2 issue above where the drop down containers would hide behind my text scroller (and I read other comments we’re people had the same issue with some graphics and videos).

      The fix is using a z-index on the drop down containers . The z-index property specifies the stack order of an element where an element with a greater stack order is always in front of an element with a lower stack order. I used a high number to make sure the menu stays on top of everything. Here is the the coding I used in the pre-existing class:

      .dropdown_1column,
      .dropdown_2columns,
      .dropdown_3columns,
      .dropdown_4columns,
      .dropdown_5columns {
      position:absolute; <== already there
      z-index: 888; <== added property
      }

      The z-index only works on positioned elements. Hope this helps those that need it.

      • Haz

        Hi, you seem to be very knowledgeable, actually I’m new to css and I want you to tell me how to insert the menu code into my design, I’m developing a joomla 2.5 website , so where should I put the html part and also the CSS part, sorry for my naive question. Thanks

        Haz

      • Steve M – www.bvgasa.org

        The CSS file is a standalone (separate) file that can be anywhere your html file can get to it. You identify the name and location of the CSS file in the head section of your html file with a statement like:

        This example used a sub-folder called css to put the file in.

        The html code goes into the body section of your html file. You place it in your existing code where you want it to show in your document. For example, if you want it on the very top, it should be the first code written after the opening of the . If you want it lower, put if after whatever text, or graphics, or whatever you desire. If you look at my web page you can see that the top row has an icon, a photo crawler and another icon. Together they cover 3 columns of a table I use for the layout of the entire page. The menu also uses all 3 columns but I limit how wide it is and align it to the right. This way it doesn’t interfere with the left column of traffic.

      • Haz

        Thank you very much for your response Steve, I’m really impressed with your webpage ..actually I’m struggling a week ago just to implement a mega menu like the one you created in your site and that’s the reason I came to this page here; well I know you can guide me through how to achieve it, thanks a lot for your time and please accept my friendship.

        I was trying to modify the values of “.sf-menu li” in superfish.css file to add extra columns with no good
        I should also tell you that this modification I’m trying to do is on a joomla 2.5 template, you can see it here: – http://hogash.com/themeforest/?theme=ammon_html
        so, I want to keep the menu content dynamic of course and at the same time give it the behavior of a mega menu with 3 or 4 column with no pictures.

        Thanx again

        Haz

  • CrazyBug

    Its not working on IE9 can i have a solution to this asap??

    • Steve M

      I have tried the menu in IE7,8,9 and 10 and it worked. I did need to go to the compatibility mode to see the rounded corners and some other very minor CSS changes. Have you tried running the demo on this site using IE9? If it works for you that way then you will know the issue is in your code on your version, not IE9. Just a thought.