CSS Only Menu

So, I recently decided I was tired of JavaScript and ASP.NET Menu controls. As a result, I challenged myself to create a CSS only menu provider. It was surprisingly easy.

First, I set up my parent and Child Menus like so:


Then, I worked my CSS to display the menus on hover of a parent item:

<div id=”MainNav”>
<li><a href=”#”>Home</a></li>
<a href=”#”>Section 1</a>
<li><a href=”#”>Subsection 1</a></li>
<li><a href=”#”>Subsection 2</a></li>
<li><a href=”#”>Subsection 3</a></li>
<li><a href=”#”>Section 2</a></li>
<li><a href=”#”>Section 3</a></li>

Finally, I made sure the child stayed displayed while you hovered over it:

#MainNav {
left: 0;
border-right: 1px solid #F3F3F3;
#MainNav ul, #RightNav ul {
margin: 0px;
padding: 0px;
#MainNav ul li, #RightNav ul li {
width: 100%;
border-bottom: 1px solid #F3F3F3;
list-style: none;
margin: 0px;
position: relative;
#MainNav ul li a, #RightNav ul li a {
padding: 20px 5px;
width: 100%;
color: #777;
text-decoration: none;
display: inline-block;
vertical-align: middle;
text-shadow: 1px 1px 3px #dbdbdb;
#MainNav ul li a:hover, #RightNav ul li a:hover {
background-color: #FFFFFF;
color: #609FF7;

#MainNav h3, #RightNav h3 {
padding: 0px 5px;
.SubMenu {
position: absolute;
top: -1;
left: 100%;
z-index: 9999;
width: 400px;
background-color: #FFF;
border: 1px solid #DBDBDB;
display: none;
.SubMenu li:first-child a {
margin-left: -1px;
background-color: #FFFFFF;
.SubMenu li {
float: left;
width: 180px !important;
border-bottom: none !important;

#MainNav ul li:hover .SubMenu {
display: inline;
#MainNav ul li .SubMenu:hover {
display: inline;

You can extend these further with CSS3 animations that can make your menus damn near works of art. But there you go, stupid simple CSS3 menus. This is great for simple menus when you really don’t want to break out a menu provider or custom JavaScript/jQuery.

As always, if you have any suggestions let me know!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: