How To Build A Kick-Butt CSS3 Mega Drop-Down Menu: Final Product What You'll Be Creating
How To Build A Kick-Butt CSS3 Mega Drop-Down Menu: Final Product What You'll Be Creating
Advertise Here
Tutorial Details
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.
1. <ul id="menu">
2. <li><a href="#">Home</a></li>
3. <li><a href="#">About</a></li>
4. <li><a href="#">Services</a></li>
5. <li><a href="#">Portfolio</a></li>
6. <li><a href="#">Contact</a></li>
7. </ul>
1. #menu {
2. list-style:none;
3. width:940px;
4. margin:30px auto 0px auto;
5. height:43px;
6. padding:0px 20px 0px 20px;
1 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
7. }
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).
1. -moz-border-radius: 10px
2. -webkit-border-radius: 10px;
3. 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.
1. background: #014464;
2. background: -moz-linear-gradient(top, #0272a7, #013953);
3. 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 :
1. #menu {
2. list-style:none;
3. width:940px;
4. margin:30px auto 0px auto;
5. height:43px;
6. padding:0px 20px 0px 20px;
7.
8. /* Rounded Corners */
9.
10. -moz-border-radius: 10px;
11. -webkit-border-radius: 10px;
12. border-radius: 10px;
13.
14. /* Background color and gradients */
15.
16. background: #014464;
17. background: -moz-linear-gradient(top, #0272a7, #013953);
18. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
19.
20. /* Borders */
21.
22. border: 1px solid #002232;
23.
24. -moz-box-shadow:inset 0px 0px 1px #edf9ff;
25. -webkit-box-shadow:inset 0px 0px 1px #edf9ff;
26. box-shadow:inset 0px 0px 1px #edf9ff;
27. }
1. #menu li {
2. float:left;
3. display:block;
4. text-align:center;
5. position:relative;
6. padding: 4px 10px 4px 10px;
7. margin-right:30px;
8. margin-top:7px;
9. border:none;
10. }
2 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
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.
1. background: #F4F4F4;
2. background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
3. 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.
Then, we add rounded corners to the top only so the drop down will stick perfectly under the parent menu item :
1. #menu li:hover {
2. border: 1px solid #777777;
3. padding: 4px 9px 4px 9px;
4.
5. /* Background color and gradients */
6.
7. background: #F4F4F4;
8. background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
9. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
10.
11. /* Rounded corners */
12.
13. -moz-border-radius: 5px 5px 0px 0px;
14. -webkit-border-radius: 5px 5px 0px 0px;
15. border-radius: 5px 5px 0px 0px;
16. }
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 :
1. #menu li a {
2. font-family:Arial, Helvetica, sans-serif;
3. font-size:14px;
4. color: #EEEEEE;
5. display:block;
6. outline:0;
7. text-decoration:none;
8. text-shadow: 1px 1px 1px #000;
9. }
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 :
1. #menu li:hover a {
2. color:#161616;
3. text-shadow: 1px 1px 1px #FFFFFF;
4. }
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) :
1. #menu li .drop {
3 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
2. padding-right:21px;
3. background:url("img/drop.png") no-repeat rightright 8px;
4. }
5. #menu li:hover .drop {
6. background:url("img/drop.png") no-repeat rightright 7px;
7. }
Here is our final code for the menu container and links; only the “home” item doesn’t have any drop down content for now :
1. <ul id="menu">
2. <li><a href="#">Home</a></li>
3. <li><a href="#" class="drop">About</a></li>
4. <li><a href="#" class="drop">Services</a></li>
5. <li><a href="#" class="drop">Portfolio</a></li>
6. <li><a href="#" class="drop">Contact</a></li>
7. </ul>
1. #menu {
2. list-style:none;
3. width:940px;
4. margin:30px auto 0px auto;
5. height:43px;
6. padding:0px 20px 0px 20px;
7.
8. /* Rounded Corners */
9.
10. -moz-border-radius: 10px;
11. -webkit-border-radius: 10px;
12. border-radius: 10px;
13.
14. /* Background color and gradients */
15.
16. background: #014464;
17. background: -moz-linear-gradient(top, #0272a7, #013953);
18. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
19.
20. /* Borders */
21.
22. border: 1px solid #002232;
23.
24. -moz-box-shadow:inset 0px 0px 1px #edf9ff;
25. -webkit-box-shadow:inset 0px 0px 1px #edf9ff;
26. box-shadow:inset 0px 0px 1px #edf9ff;
27. }
28.
29. #menu li {
30. float:left;
31. display:block;
32. text-align:center;
33. position:relative;
34. padding: 4px 10px 4px 10px;
35. margin-right:30px;
36. margin-top:7px;
37. border:none;
38. }
39.
40. #menu li:hover {
41. border: 1px solid #777777;
42. padding: 4px 9px 4px 9px;
43.
44. /* Background color and gradients */
45.
46. background: #F4F4F4;
47. background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
48. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
49.
50. /* Rounded corners */
51.
52. -moz-border-radius: 5px 5px 0px 0px;
53. -webkit-border-radius: 5px 5px 0px 0px;
54. border-radius: 5px 5px 0px 0px;
55. }
56.
57. #menu li a {
58. font-family:Arial, Helvetica, sans-serif;
59. font-size:14px;
60. color: #EEEEEE;
61. display:block;
62. outline:0;
4 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
63. text-decoration:none;
64. text-shadow: 1px 1px 1px #000;
65. }
66.
67. #menu li:hover a {
68. color:#161616;
69. text-shadow: 1px 1px 1px #FFFFFF;
70. }
71. #menu li .drop {
72. padding-right:21px;
73. background:url("img/drop.png") no-repeat rightright 8px;
74. }
75. #menu li:hover .drop {
76. background:url("img/drop.png") no-repeat rightright 7px;
77. }
1. <ul id="menu">
2. <li><a href="#">Item 1</a><
3. <ul>
4. <li><a href="#">Subitem 1</a></li>
5. <li><a href="#">Subitem 2</a></li>
6. <li><a href="#">Subitem 3</a></li>
7. </ul>
8. </li>
9. <li><a href="#">Item 2</a><
10. <ul>
11. <li><a href="#">Subitem 1</a></li>
12. <li><a href="#">Subitem 2</a></li>
13. </ul>
14. </li>
15. </ul>
General Structure
For our Mega Menu, instead of nested lists, we’ll simply use standard DIVs, which will work like any nested list :
1. <ul id="menu">
2. <li><a href="#">Item 1</a>
3. <div>
4. Drop down Content
5. <div>
6. </li>
7. <li><a href="#">Item 2</a>
8. <div>
9. Drop down Content
10. <div>
11. </li>
12. </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.
To hide the drop downs, we’ll use absolute positioning with a negative left margin :
1. position:absolute;
2. 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
5 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
parent menu item gradient) and ending with #BBBBBB at the bottom:
1. background:#F4F4F4;
2. background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
3. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));
We’ll again use rounded corners, except for the top left one :
1. .dropdown_1column,
2. .dropdown_2columns,
3. .dropdown_3columns,
4. .dropdown_4columns,
5. .dropdown_5columns {
6. margin:4px auto;
7. position:absolute;
8. left:-999em; /* Hides the drop down */
9. text-align:left;
10. padding:10px 5px 10px 5px;
11. border:1px solid #777777;
12. border-top:none;
13.
14. /* Gradient background */
15. background:#F4F4F4;
16. background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
17. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));
18.
19. /* Rounded Corners */
20. -moz-border-radius: 0px 5px 5px 5px;
21. -webkit-border-radius: 0px 5px 5px 5px;
22. border-radius: 0px 5px 5px 5px;
23. }
To illustrate this, let’s see how it would look if we hadn’t paid attention to detail:
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 :
6 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
And to show the drop downs on mouse hover, we’ll simply use :
1. <ul id="menu">
2. <li><a href="#">Home</a></li>
3. <li><a href="#" class="drop">5 Columns</a>
4. <div class="dropdown_5columns">
5. <p>5 Columns content</p>
6. </div>
7. </li>
8. <li><a href="#" class="drop">4 Columns</a>
9. <div class="dropdown_4columns">
10. <p>4 Columns content</p>
11. </div>
12. </li>
13. <li><a href="#" class="drop">3 Columns</a>
14. <div class="dropdown_3columns">
15. <p>3 Columns content</p>
16. </div>
17. </li>
18. <li><a href="#" class="drop">2 Columns</a>
19. <div class="dropdown_2columns">
20. <p>2 Columns content</p>
21. </div>
22. </li>
23. <li><a href="#" class="drop">1 Column</a>
24. <div class="dropdown_1column">
25. <p>1 Column content</p>
26. </div>
27. </li>
28. </ul>
1. .col_1,
2. .col_2,
3. .col_3,
4. .col_4,
5. .col_5 {
6. display:inline;
7. float: left;
8. position: relative;
9. margin-left: 5px;
10. margin-right: 5px;
11. }
12. .col_1 {width:130px;}
13. .col_2 {width:270px;}
14. .col_3 {width:410px;}
7 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
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 :
1. <ul id="menu">
2. <li><a href="#" class="drop">5 Columns</a>
3. <div class="dropdown_5columns">
4. <div class="col_5">
5. <p>This is a 5 Columns content</p>
6. </div>
7. <div class="col_1">
8. <p>This is a 1 Column content</p>
9. </div>
10. <div class="col_1">
11. <p>This is a 1 Column content</p>
12. </div>
13. <div class="col_1">
14. <p>This is a 1 Column content</p>
15. </div>
16. <div class="col_1">
17. <p>This is a 1 Column content</p>
18. </div>
19. <div class="col_1">
20. <p>This is a 1 Column content</p>
21. </div>
22. <div class="col_4">
23. <p>This is a 4 Columns content</p>
24. </div>
25. <div class="col_1">
26. <p>This is a 1 Column content</p>
27. </div>
28. <div class="col_3">
29. <p>This is a 3 Columns content</p>
30. </div>
31. <div class="col_2">
32. <p>This is a 2 Columns content</p>
33. </div>
34. </div>
35. </li>
36. </ul>
Code preview :
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 :
1. #menu .menu_right {
2. float:rightright;
3. margin-right:0px;
4. }
8 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
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.
1. #menu li .align_right {
2. /* Rounded Corners */
3. -moz-border-radius: 5px 0px 5px 5px;
4. -webkit-border-radius: 5px 0px 5px 5px;
5. border-radius: 5px 0px 5px 5px;
6. }
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 :
General Stylings
Let’s begin with some basic styling for paragraphs and headings :
9 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
We can apply a nice blue color to the links within the drop down :
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 :
1. #menu li ul {
2. list-style:none;
3. padding:0;
4. margin:0 0 12px 0;
5. }
6. #menu li ul li {
7. font-size:12px;
8. line-height:24px;
9. position:relative;
10. text-shadow: 1px 1px 1px #ffffff;
11. padding:0;
12. margin:0;
13. float:none;
14. text-align:left;
15. width:130px;
16. }
17. #menu li ul li:hover {
18. background:none;
19. border:none;
20. padding:0;
21. margin:0;
22. }
Styling Images
view plaincopy to clipboardprint?
1. .imgshadow {
2. background:#FFFFFF;
3. padding:4px;
4. border:1px solid #777777;
5. margin-top:5px;
6. -moz-box-shadow:0px 0px 5px #666666;
7. -webkit-box-shadow:0px 0px 5px #666666;
8. box-shadow:0px 0px 5px #666666;
9. }
1. .img_left {
2. width:auto;
3. float:left;
4. margin:5px 15px 5px 5px;
5. }
Text Boxes
To highlight some content, here is an example of a dark box with rounded corners and a subtle inset shadow :
10 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
1. #menu li .black_box {
2. background-color:#333333;
3. color: #eeeeee;
4. text-shadow: 1px 1px 1px #000;
5. padding:4px 6px 4px 6px;
6.
7. /* Rounded Corners */
8. -moz-border-radius: 5px;
9. -webkit-border-radius: 5px;
10. border-radius: 5px;
11.
12. /* Shadow */
13. -webkit-box-shadow:inset 0 0 3px #000000;
14. -moz-box-shadow:inset 0 0 3px #000000;
15. box-shadow:inset 0 0 3px #000000;
16. }
Restylings Lists
And to finish, here’s another way to style your lists using, again, some CSS3 :
1. #menu li .greybox li {
2. background:#F4F4F4;
3. border:1px solid #bbbbbb;
4. margin:0px 0px 4px 0px;
5. padding:4px 6px 4px 6px;
6. width:116px;
7.
8. /* Rounded Corners */
9. -moz-border-radius: 5px;
10. -webkit-border-radius: 5px;
11. border-radius: 5px;
12. }
13. #menu li .greybox li:hover {
14. background:#ffffff;
15. border:1px solid #aaaaaa;
16. padding:4px 6px 4px 6px;
17. margin:0px 0px 4px 0px;
18. }
1. <!--[if IE 6]>
2. <style>
3. body {behavior: url("csshover3.htc");}
4. </style>
5. <![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 :
I’ll let you choose the one that fits to your needs. Now, let’s review a full working example.
11 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
Final Example
HTML Part
view plaincopy to clipboardprint?
12 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
13 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
14 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
237. </ul>
238.
239. </div>
240.
241. <div class="col_3">
242. <h2>Here are some image examples</h2>
243. </div>
244.
245. <div class="col_3">
246. <img src="img/02.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
247. <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
</a></p>
248.
249. <img src="img/01.jpg" width="70" height="70" class="img_left imgshadow" alt="" />
250. <p>Aliquam elementum felis quis felis consequat scelerisque. Fusce sed lectus at arcu mollis accumsan at nec nisi. Aliquam pretium mollis fringilla. Vestibulum tempor fac
</a></p>
251. </div>
252.
253. </div>
254.
255. </li>
256.
257. </ul>
258.
259. </body>
260.
261. </html>
CSS Part
view plaincopy to clipboardprint?
1. body, ul, li {
2. font-size:14px;
3. font-family:Arial, Helvetica, sans-serif;
4. line-height:21px;
5. text-align:left;
6. }
7.
8. /* Navigation Bar */
9.
10. #menu {
11. list-style:none;
12. width:940px;
13. margin:30px auto 0px auto;
14. height:43px;
15. padding:0px 20px 0px 20px;
16.
17. /* Rounded Corners */
18.
19. -moz-border-radius: 10px;
20. -webkit-border-radius: 10px;
21. border-radius: 10px;
22.
23. /* Background color and gradients */
24.
25. background: #014464;
26. background: -moz-linear-gradient(top, #0272a7, #013953);
27. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0272a7), to(#013953));
28.
29. /* Borders */
30.
31. border: 1px solid #002232;
32.
33. -moz-box-shadow:inset 0px 0px 1px #edf9ff;
34. -webkit-box-shadow:inset 0px 0px 1px #edf9ff;
35. box-shadow:inset 0px 0px 1px #edf9ff;
36. }
37.
38. #menu li {
39. float:left;
40. text-align:center;
41. position:relative;
42. padding: 4px 10px 4px 10px;
43. margin-right:30px;
44. margin-top:7px;
45. border:none;
46. }
47.
48. #menu li:hover {
49. border: 1px solid #777777;
50. padding: 4px 9px 4px 9px;
15 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
51.
52. /* Background color and gradients */
53.
54. background: #F4F4F4;
55. background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE);
56. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F4F4F4), to(#EEEEEE));
57.
58. /* Rounded corners */
59.
60. -moz-border-radius: 5px 5px 0px 0px;
61. -webkit-border-radius: 5px 5px 0px 0px;
62. border-radius: 5px 5px 0px 0px;
63. }
64.
65. #menu li a {
66. font-family:Arial, Helvetica, sans-serif;
67. font-size:14px;
68. color: #EEEEEE;
69. display:block;
70. outline:0;
71. text-decoration:none;
72. text-shadow: 1px 1px 1px #000;
73. }
74.
75. #menu li:hover a {
76. color:#161616;
77. text-shadow: 1px 1px 1px #FFFFFF;
78. }
79. #menu li .drop {
80. padding-right:21px;
81. background:url("img/drop.png") no-repeat rightright 8px;
82. }
83. #menu li:hover .drop {
84. background:url("img/drop.png") no-repeat rightright 7px;
85. }
86.
87. /* Drop Down */
88.
89. .dropdown_1column,
90. .dropdown_2columns,
91. .dropdown_3columns,
92. .dropdown_4columns,
93. .dropdown_5columns {
94. margin:4px auto;
95. float:left;
96. position:absolute;
97. left:-999em; /* Hides the drop down */
98. text-align:left;
99. padding:10px 5px 10px 5px;
100. border:1px solid #777777;
101. border-top:none;
102.
103. /* Gradient background */
104. background:#F4F4F4;
105. background: -moz-linear-gradient(top, #EEEEEE, #BBBBBB);
106. background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EEEEEE), to(#BBBBBB));
107.
108. /* Rounded Corners */
109. -moz-border-radius: 0px 5px 5px 5px;
110. -webkit-border-radius: 0px 5px 5px 5px;
111. border-radius: 0px 5px 5px 5px;
112. }
113.
114. .dropdown_1column {width: 140px;}
115. .dropdown_2columns {width: 280px;}
116. .dropdown_3columns {width: 420px;}
117. .dropdown_4columns {width: 560px;}
118. .dropdown_5columns {width: 700px;}
119.
120. #menu li:hover .dropdown_1column,
121. #menu li:hover .dropdown_2columns,
122. #menu li:hover .dropdown_3columns,
123. #menu li:hover .dropdown_4columns,
124. #menu li:hover .dropdown_5columns {
125. left:-1px;
126. top:auto;
127. }
128.
129. /* Columns */
130.
131. .col_1,
132. .col_2,
16 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
133. .col_3,
134. .col_4,
135. .col_5 {
136. display:inline;
137. float: left;
138. position: relative;
139. margin-left: 5px;
140. margin-right: 5px;
141. }
142. .col_1 {width:130px;}
143. .col_2 {width:270px;}
144. .col_3 {width:410px;}
145. .col_4 {width:550px;}
146. .col_5 {width:690px;}
147.
148. /* Right alignment */
149.
150. #menu .menu_right {
151. float:rightright;
152. margin-right:0px;
153. }
154. #menu li .align_right {
155. /* Rounded Corners */
156. -moz-border-radius: 5px 0px 5px 5px;
157. -webkit-border-radius: 5px 0px 5px 5px;
158. border-radius: 5px 0px 5px 5px;
159. }
160. #menu li:hover .align_right {
161. left:auto;
162. rightright:-1px;
163. top:auto;
164. }
165.
166. /* Drop Down Content Stylings */
167.
168. #menu p, #menu h2, #menu h3, #menu ul li {
169. font-family:Arial, Helvetica, sans-serif;
170. line-height:21px;
171. font-size:12px;
172. text-align:left;
173. text-shadow: 1px 1px 1px #FFFFFF;
174. }
175. #menu h2 {
176. font-size:21px;
177. font-weight:400;
178. letter-spacing:-1px;
179. margin:7px 0 14px 0;
180. padding-bottom:14px;
181. border-bottom:1px solid #666666;
182. }
183. #menu h3 {
184. font-size:14px;
185. margin:7px 0 14px 0;
186. padding-bottom:7px;
187. border-bottom:1px solid #888888;
188. }
189. #menu p {
190. line-height:18px;
191. margin:0 0 10px 0;
192. }
193.
194. #menu li:hover div a {
195. font-size:12px;
196. color:#015b86;
197. }
198. #menu li:hover div a:hover {
199. color:#029feb;
200. }
201. .strong {
202. font-weight:bold;
203. }
204. .italic {
205. font-style:italic;
206. }
207. .imgshadow {
208. background:#FFFFFF;
209. padding:4px;
210. border:1px solid #777777;
211. margin-top:5px;
212. -moz-box-shadow:0px 0px 5px #666666;
213. -webkit-box-shadow:0px 0px 5px #666666;
214. box-shadow:0px 0px 5px #666666;
17 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
215. }
216. .img_left { /* Image sticks to the left */
217. width:auto;
218. float:left;
219. margin:5px 15px 5px 5px;
220. }
221. #menu li .black_box {
222. background-color:#333333;
223. color: #eeeeee;
224. text-shadow: 1px 1px 1px #000;
225. padding:4px 6px 4px 6px;
226.
227. /* Rounded Corners */
228. -moz-border-radius: 5px;
229. -webkit-border-radius: 5px;
230. border-radius: 5px;
231.
232. /* Shadow */
233. -webkit-box-shadow:inset 0 0 3px #000000;
234. -moz-box-shadow:inset 0 0 3px #000000;
235. box-shadow:inset 0 0 3px #000000;
236. }
237. #menu li ul {
238. list-style:none;
239. padding:0;
240. margin:0 0 12px 0;
241. }
242. #menu li ul li {
243. font-size:12px;
244. line-height:24px;
245. position:relative;
246. text-shadow: 1px 1px 1px #ffffff;
247. padding:0;
248. margin:0;
249. float:none;
250. text-align:left;
251. width:130px;
252. }
253. #menu li ul li:hover {
254. background:none;
255. border:none;
256. padding:0;
257. margin:0;
258. }
259. #menu li .greybox li {
260. background:#F4F4F4;
261. border:1px solid #bbbbbb;
262. margin:0px 0px 4px 0px;
263. padding:4px 6px 4px 6px;
264. width:116px;
265.
266. /* Rounded Corners */
267. -moz-border-radius: 5px;
268. -webkit-border-radius: 5px;
269. border-radius: 5px;
270. }
271. #menu li .greybox li:hover {
272. background:#ffffff;
273. border:1px solid #aaaaaa;
274. padding:4px 6px 4px 6px;
275. margin:0px 0px 4px 0px;
276. }
Conclusion
I hope you’ve enjoyed this tutorial on creating mega menus. Thanks for following along!
18 of 19 10/14/10 9:47 AM
How to Build a Kick-Butt CSS3 Mega Drop-Down Menu | Ne... http://net.tutsplus.com/tutorials/html-css-techniques/how-to-b...
By Guillaume Marty
This author has yet to write their bio.
19 of 19 10/14/10 9:47 AM