Sliding Navigation Bar Css - css

I'm trying to build a navigation bar where the sub menus slide in from the side of the page using css. I'm having the problem that when the sub menus slide in the position of the parent menu items changes. I have made a fiddle here http://jsfiddle.net/CL7d7/ can someone suggest where I have gone wrong.
html
<ul>
<li>Home</li>
<li>
<a class="box" href="#">Weddings</a>
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</li>
<li>Biography</li>
<li>Services</li>
<li>Photobooth</li>
</ul>
</div><!-- end #nav -->
css
#wrap{
width:500px;
overflow: hidden;
}
#nav {
height: 35px;
width: 500px;
font-size: 13px;
font-family: Tahoma, Geneva, sans-serif;
font-weight: bold;
text-shadow: 1px 1px 1px #EEE;
background-color: transparent;
z-index: 1;
}
#nav ul {
height: auto;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#nav li {
float: left;
margin-right: 5px;
margin-left: 5px;
display: inline;
}
#nav ul a{
text-decoration: none;
display: block;
padding-top: 10px;
width: 80px;
text-align: center;
height: 20px;
color: #666;
margin: 0px;
}
#nav a:hover {
color: #999999;
}
#nav a:active {
background-color: transparent;
}
#nav ul ul {
text-shadow: 1px 1px 1px #EEE;
z-index: 2;
/*display:none;*/
padding-left: 0px;
top: 35px;
transition: right 1s;
-moz-transition: right 1s; /* Firefox 4 */
-webkit-transition: right 1s; /* Safari and Chrome */
-o-transition: right 1s; /* Opera */
-ms-transition: right 1s;
right: -500px;
position: absolute;
float: left;
}
#nav ul ul li {
display: inline;
}
#nav ul ul a {
color: #F9C;
font-size: 12px;
width: 80px;
height: 35px;
}
#nav ul ul a:hover {
display: block;
color: #99999;
font-size: 12px;
position: absolute;
}
#nav ul li:hover > ul {
overflow: hidden;
right: 0px;
display: block;
top: 0px;
position: relative;
}
#nav ul ul li {
display: inline;
}
#nav ul ul a {
color: #F9C;
font-size: 12px;
width: 80px;
height: 35px;
}
#nav ul ul a:hover {
display: block;
color: #99999;
font-size: 12px;
position: absolute;
}
#nav ul li:hover > ul {
overflow: hidden;
right: 0px;
display: block;
top: 0px;
position: relative;
}
#nav li:hover > a {
color: #99999;
display: block;
}
#nav li:hover > a {
color: #99999;
display: block;
}

Change your positioning to absolute in #nav ul li:hover > ul. Also set top property for alignment.
It should be like this:
#nav ul li:hover > ul {
overflow: hidden;
right: 0px;
display: block;
top: 40px;
position: absolute;
}
And here is the fiddle

Related

Background color does not cover entire <a>-element when hovered

I am currently coding a navigation bar where when the links are hovered, the background-color of the -element changes. Currently, the background-color in the navigation bar's dropdown menu does not cover the entire "box".
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: black;
}
ul li {
display: inline-block;
position: relative;
background-color: black;
}
ul li a {
display: block;
color: white;
text-decoration: none;
text-align: center;
margin: -left:0;
padding: 15px 25px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
}
ul li a:hover {
background-color: #333;
}
ul li ul#dropdowncontent {
display: inline-block;
position: absolute;
text-align: center;
min-width: 100%;
font-size: 70%;
z-index: 999;
width: 90px;
}
<ul>
<li>Produkter
<ul id="dropdowncontent">
<li>Moderkort</li>
<li>Processorer</li>
<li>Hårddiskar</li>
<li>Grafikkort</li>
</ul>
</li>
<li>Butiker</li>
<li>Kontakt</li>
<li>Vanliga frågor</li>
</ul>
You can also take a look at the code in this Jsfiddle: https://jsfiddle.net/fdvcmnx6/
Set your dropdown list items to display: block.
#dropdowncontent li {
display: block;
}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: black;
}
ul li {
display: inline-block;
position: relative;
background-color: black;
}
ul li a {
display: block;
color: white;
text-decoration: none;
text-align: center;
margin: -left:0;
padding: 15px 25px;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;
}
ul li a:hover {
background-color: #333;
}
ul li ul#dropdowncontent {
display: inline-block;
position: absolute;
text-align: center;
min-width: 100%;
font-size: 70%;
z-index: 999;
width: 90px;
}
/* Additional */
#dropdowncontent li {
display: block;
}
<ul>
<li>Produkter
<ul id="dropdowncontent">
<li>Moderkort</li>
<li>Processorer</li>
<li>Hårddiskar</li>
<li>Grafikkort</li>
</ul>
</li>
<li>Butiker</li>
<li>Kontakt</li>
<li>Vanliga frågor</li>
</ul>
set your dropdown list width:100%
#dropdowncontent li {
display: block;
}

Centering with CSS

I want to set my drop down menu in the middle of my page. I could make it both left aligned or centered, but now it is not working anymore.
#navigation {
margin-top: -50;
background: #000;
height: 3em;
list-style: none;
position: center;
color: #fff;
font-family: Arial;
font-size: 14px;
z-index: +1;
}
#navigation > li {
position: relative;
left:15%;
display: inline;
height: 100%;
margin-right: 0.5em;
padding: 0 1cm 0 1cm;
z-index: 2;
}
#navigation > li > a {
position: relative;
left:15%;
display: inline;
height: 100%;
color: #c60;
text-decoration: none;
line-height: 3;
font-weight: bold;
text-transform: uppercase;
z-index: 2;
}
#navigation > li > a:hover {
color: orange;
text-decoration: underline;
display: inline;
}
#navigation > li.sub {
position: relative;
display: inline;
}
#navigation > li.sub ul {
width: 10em;
margin: 0;
padding: 0.5em 0;
list-style: none;
background: #a40;
position: absolute;
left:50%;
display: inline;
top: -1000em;
z-index: +2;
}
#navigation > li.sub ul li {
width: 90%;
margin: 0 auto 0.3em auto;
display: inline;
z-index: +2;
}
#navigation > li.sub ul li a {
height: 100%;
display: block;
padding: 0.4em;
color: #fff;
font-weight: bold;
text-decoration: none;
}
#navigation > li.sub ul li a:hover {
background: #c60;
text-decoration: underline;
display: inline;
}
#navigation > li.sub:hover ul {
top: 3em;
z-index: +2;
}
This code used to make the menu centered but it's not working anymore.
Since you haven't provided a snippet of the HTML code for your navigation dropdown, I went ahead and did some detective work to figure it out. So given that the HTML structure is something like this:
<ul id="navigation">
<li class="sub">
<a>option</a>
<ul>
<li><a>sub-option</a></li>
<li><a>sub-option</a></li>
</ul>
</li>
<li class="sub">
<a>option</a>
<ul>
<li><a>sub-option</a></li>
<li><a>sub-option</a></li>
</ul>
</li>
<li>
<a>lonely option</a>
</li>
</ul>
I noticed that there were a few problems in your CSS, I've added comments below to discuss these. So this is your current CSS:
#navigation {
margin-top: -50; /* <-- missing measurement unit, px? em? */
background: #000;
height: 3em;
list-style: none;
position: center; /* <-- no such thing as 'center' */
color: #fff;
font-family: Arial;
font-size: 14px;
z-index: +1; /* <-- not a big deal but you can leave out the plus for positive integers. */
}
#navigation > li {
position: relative;
left:15%; /* <-- this one ... */
display: inline;
height: 100%;
margin-right: 0.5em;
padding: 0 1cm 0 1cm;
z-index: 2;
}
#navigation > li > a {
position: relative;
left:15%; /* <-- ... and this were the ones causing you grief */
display: inline;
height: 100%;
color: #c60;
text-decoration: none;
line-height: 3;
font-weight: bold;
text-transform: uppercase;
z-index: 2;
}
#navigation > li > a:hover {
color: orange;
text-decoration: underline;
display: inline;
}
#navigation > li.sub {
position: relative;
display: inline;
}
#navigation > li.sub ul {
width: 10em;
margin: 0;
padding: 0.5em 0;
list-style: none;
background: #a40;
position: absolute;
left:50%;
display: inline;
top: -1000em;
z-index: +2;
}
#navigation > li.sub ul li {
width: 90%;
margin: 0 auto 0.3em auto;
display: inline;
z-index: +2;
}
#navigation > li.sub ul li a {
height: 100%;
display: block;
padding: 0.4em;
color: #fff;
font-weight: bold;
text-decoration: none;
}
#navigation > li.sub ul li a:hover {
background: #c60;
text-decoration: underline;
display: inline;
}
#navigation > li.sub:hover ul {
top: 3em;
z-index: +2;
}
This is the current state of the navigation dropdown. Before I could solve your issue, I had to fix the following problems:
Removed the rule position: center; from #navigation {} as it is
not a valid rule and wasn't doing anything
Removed the rule left: 15% from #navigation > li {} and #navigation > li > a. Using these two rules to try and center was not only not truly centering the dropdown but causing it to break as well.
Removed the rule margin-top: -50; as it was not doing anything
Changed display: inline; to display: inline-block; in #navigation > li {}. This way height: 100%; would make the height of the li element the same height as the navigation bar.
Now with all that out of the way - all you need to do is, instead of using position: center you need to use text-align: center in #navigation {}. That will center your navigation.
Finally, here is the updated and working navigation dropdown demo and code.

Is there a way to display a dropdown menu inside/on top of the parent body in pure CSS

I'm looking to make a dropdown menu that shows up inside/on top of the parent menu. I would like to do this in pure css. I have made a quick example of what I am looking for(in Photoshop). Here is a link. Here is what I have now, but this makes a normal dropdown menu and not one that stays in the parent container.
CSS:
.titlebox ul {
text-align: center;
font-size: 15px;
font-family: arial,sans-serif;
line-height: 32px;
margin: 0;
width: 100%;
background: #555;
list-style: none;
border-radius: 2px !important;
transition: all 0.15s ease;
}
.titlebox ul:hover {background: #666;}
.titlebox ul:active {background: #444;}
.titlebox ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 32px !important;
}
.titlebox ul li:hover {
background: #666;
}
.titlebox ul li:hover ul {
display: inline;
opacity: 1;
visibility: visible;
}
.titlebox ul li ul {
padding: 0;
position: absolute;
top: 0px;
right: 0px;
display: none;
opacity: 0;
visibility: hidden;
}
.titlebox ul li ul li {
display: inline;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
.titlebox ul li ul li:hover {background: #666;}
HTML(Quick):
<ul>
<li>Hi<br/>
<ul>
<li>Google<br/></li>
<li>HOLA<br/></li>
<li>HALO<br/></li>
</ul></li>
</ul>
Any and all help is appreciated! I know this might be kinda confusing but I don't know how else to explain it. If you have any questions, feel free to ask!
Thanks,
Usama Khan
EDIT 1: Here's the link to the JSFiddle.
i think this is your looking for .if not ,can you tell me where i am wrong.
ul {
text-align: center;
font-size: 15px;
font-family: arial, sans-serif;
line-height: 32px;
margin: 0;
padding: 0;
width: 300px;
background: #555;
list-style: none;
border-radius: 2px !important;
transition: all 0.15s ease;
}
ul:hover {
background: #666;
}
ul:active {
background: #444;
}
ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 32px !important;
}
ul li:hover {
background: #666;
}
ul li:hover ul {
display: inline;
opacity: 1;
visibility: visible;
margin-left:10px;
}
ul li ul {
padding: 0;
position: absolute;
top: 0px;
right: 0px;
display: none;
opacity: 0;
visibility: hidden;
}
ul li ul li {
display: inline;
color: #fff;
text-shadow: 0 -1px 0 #000;
float: left;
width: 33%;
}
ul li ul li:hover a{
color: white;
}
ul li ul li:hover {
background: #777;
}
<body>
<ul>
<li>Hi
<ul>
<li>Google1</li>
<li>Google2</li>
<li>Google3</li>
</ul>
</li>
</ul>
</body>
The HTML
I removed the /br from the html, because it was forcing the navigation menu to drop down.
<body>
<ul>
<li>Hi
<ul>
<li>HOLA</li>
<li>HALO</li>
</ul>
</li>
</ul>
</body>
The CSS
Read the comments in the css for all changes / explanation (ask if there is something you do not understand). I also removed a lot of unnecessary css from your code (and some of it probably still is).
ul {
text-align: center;
font-size: 15px;
font-family: arial, sans-serif;
line-height: 32px;
margin: 0 auto;/*center nav-menu*/
padding: 0;
width: 300px;
background: #555;
list-style: none;
border-radius: 2px;
}
/*unnecessary now
ul:hover {
background: #666;*/
}
ul:active {
background: #444;
}
ul li {
display: block;
color: #fff;
position: relative;
width: 100%;
height: 100%;
}
/*unnecessary now
ul li:hover {
background: #666;
}*/
/*hide ul and making it the same dimensions as its parent*/
ul li ul {
padding: 0;
position: absolute;
left: 0px;
right: 0px;
top:0px;
bottom: 0px;
display: none;
}
/*make submenu appear on hover of ul*/
ul li:hover ul {
display: block;
}
/*style the subnavigation-list*/
ul li ul li {
display: block;
width: 50%;/*accomidates for 2 list items, adding more will drop them below*/
float: left;
}
/*style your buttons*/
ul li ul li a{
text-decoration: none;
color: white;
text-shadow: 0 -1px 0 #000;
display: block;
height: 100%;
width: 100%;
background-color: #555;
box-shadow: 0px 0px 1px 1px white inset;
}
/*style button on hover*/
ul li ul li a:hover{
background-color: #999;
}
JSFiddle

Vertical Drop Down Menu

I am trying to create a drop down menu similar to the one found on this website http://yachtbelleaimee.com/
I have created the drop down menu however I do not know how to position the lists like that found in the website. And like the website I would also like to known how to position the list below the header. Thank you very much for any help you can provide
/* NAVIGATION START */
nav {
display: block;
width: 960px;
margin: 100px auto;
text-align: center;
}
nav select {
display: none;
}
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
#menu ul {
margin: 0px;
padding: 0px;
}
#menu ul li {
background-color: #666;
float: left;
border: 1px solid #CCC;
position: relative;
list-style-type: none;
}
#menu ul li:hover ul {
visibility: visible;
background-color: #333;
}
#menu ul li a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-decoration: none;
text-align: center;
display: block;
height: 30px;
width: 150px;
}
#menu ul ul {
position: absolute;
visibility: hidden;
left: -1px;
top: 31px;
}
#menu ul li:hover {
background-color: #333;
}
#menu ul li ul li a:hover {
background-color: #069;
}
#menu ul li a:hover {
color: #0FF;
}
#leftmenu {
position: absolute;
left: 165px;
top: 20px;
}
#rightmenu {
position: absolute;
right: 164px;
top: 20px;
}
/* NAVIGATION END */
<nav>
<div id="menu">
<ul id='leftmenu'>
<li>BOAT
<ul>
<li><a href='#'>Specs & Boat Plans</a></li>
<li><a href='#'>Itineraries</a></li>
<li><a href='#'>Exteriors</a></li>
<li><a href='#'>Diving & Water Toys</a></li>
</ul>
</li>
</ul>
<ul id='rightmenu'>
<li>LIFE ON BOARD
<ul>
<li><a href='#'>Itineraries</a></li>
<li><a href='#'>Dining</a></li>
<li><a href='#'>Family Fun</a></li>
<li>Lifelong Learning</li>
<li>The Crew</li>
</ul>
</li>
</ul>
</div>
</nav>
Here's some CSS to get you started:
/* NAVIGATION START */
nav {
display: block;
width: 960px;
margin: 100px auto;
text-align: center;
}
nav select {
display: none;
}
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
#menu ul {
margin: 0px;
padding: 0px;
}
#menu ul li {
background-color: #666;
float: left;
border: 1px solid #CCC;
position: relative;
list-style-type: none;
}
#menu ul li:hover ul {
visibility: visible;
}
#menu ul li a {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-decoration: none;
text-align: center;
display: block;
height: 30px;
width: 150px;
}
#menu ul ul {
position: absolute;
visibility: hidden;
left: -1px;
top: 31px;
}
#menu ul li:hover {
background-color: #333;
}
#menu ul li ul li a:hover {
background-color: #069;
}
#menu ul li a:hover {
color: #0FF;
}
#leftmenu {
position: absolute;
left: 165px;
top: 20px;
}
#leftmenu li>ul>li {
margin:1em 0;
}
#leftmenu li:nth-child(2) {
margin-left:20px;
}
#leftmenu li:nth-child(3) {
margin-left:40px;
}
#leftmenu li:nth-child(4) {
margin-left:60px;
}
#rightmenu {
position: absolute;
right: 164px;
top: 20px;
}
#rightmenu li>ul>li {
margin:1em 0;
}
#rightmenu li:nth-child(2) {
margin-left:-20px;
}
#rightmenu li:nth-child(3) {
margin-left:-40px;
}
#rightmenu li:nth-child(4) {
margin-left:-60px;
}
#rightmenu li:nth-child(5) {
margin-left:-80px;
}
And a JSFiddle.
You can simplify
#menu {
width: 608px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
to
#menu {
width: 608px;
margin: 0px auto;
padding: 0px;
}
For that... er... cascading effect, you'll probably have to use something like
<li style="padding-left: some value here">
and decrease it with each <li> (since you're floating them right). Also, the menu will have to be as wide as the space that goes from the leftmost menu item to the rightmost; it cannot be as wide as one menu item.

My CSS drop down menu has a space between it and the right border. How do I remove it?

I created a css drop down menu and i am finishing it up with a border. When i added the left and bottom border everything was fine. Once i added the right border it put a gap between the right border and the drop down menu. Is there anyway to fix this?
Here is a photo http://sphotos-b.ak.fbcdn.net/hphotos-ak-ash3/563034_641717089180441_1749213926_n.jpg
The HTML I Used:
<nav id="main_nav" class="fluid">
<ul>
<li>Home</li>
<li>Show Services
<ul>
<li>Audio</li>
<li>Lighting</li>
<li>Power</li>
<li>Special Effects</li>
<li>Staging/Trussing</li>
<li>Video</li>
</ul>
</li>
<li>Systems Integration
<ul>
<li>Corporate and Commercial</li>
<li>Digital Signage</li>
<li>Entertainment</li>
<li>IP Based Systems</li>
</ul>
</li>
<li>Portfolio
<ul>
<li>Concrets</li>
<li>Installations</li>
<li>Parties</li>
<li>Product Launch</li>
<li>Trade Shows</li>
</ul>
</li>
<li>Our Company</li>
</ul>
</nav>
The CSS I Used:
#main_nav {
}
#main_nav ul {
list-style-type: none;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
width: 100%;
position: relative;
float: left;
}
#main_nav ul li {
float: left;
position: relative;
width: 20%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li a {
width: 100%;
float: left;
text-align: center;
text-transform: uppercase;
color: #FFFFFF;
text-decoration: none;
padding-top: 0%;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 1em;
display: block;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
border-left: 0.1em solid #999999;
border-bottom: 0.1em solid #999999;
border-right: 0.1em solid #999999;
}
#main_nav a:hover, #main_nav a:active, #main_nav a:focus, #main_nav a.thispage {
background-color: #666666;
color: #0099FF;
width: 100%;
}
#main_nav ul li ul {
visibility: hidden;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
float: left;
list-style-type: none;
position: absolute;
margin-top: 100%;
padding-top: 0%;
width: 100%;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
}
#main_nav ul li ul li {
position: relative;
float: left;
width: 100%;
margin-top: 0%;
margin-right: 0%;
margin-bottom: 0%;
margin-left: 0%;
padding-top: 0%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
background-color: #4d4d4d;
}
#main_nav ul li ul li a {
width: 100%;
padding-right: 0%;
padding-bottom: 0%;
padding-left: 0%;
margin-top: 0%;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
padding-top: 0%;
float: left;
font-style: normal;
font-weight: 400;
font-family: allerta;
font-size: 0.9em;
text-align: center;
text-decoration: none;
display: block;
color: #FFFFFF;
text-transform: uppercase;
}
#main_nav ul li:hover ul, #main_nav ul li:active ul, #main_nav ul li:focus ul, #main_nav ul li.thispage ul {
visibility: visible;
width: 100%;
}
I took a look at your code and have made some changes. Also took the liberty of creating a JS Fiddle example for you. I haven't changed any HTML, only the CSS.
See JS Fiddle here
html {
font: 100%/1.5 Arial, Helvetica, sans-serif;
}
html, body {
margin: 0;
}
/* Common (Shared) Properties */
#main_nav, ul, li, a {
display: block;
margin: 0;
padding: 0;
}
#main_nav ul {
list-style: none;
width: 100%;
position: relative;
float: left;
}
#main_nav li {
float: left;
position: relative;
width: 20%;
background: #4d4d4d;
}
#main_nav a {
float: none;
text-align: center;
text-transform: uppercase;
color: #FFF;
text-decoration: none;
font-size: 1em;
border: 1px solid #999;
border-top: none;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #FFF;
}
/* Controls Dropdown */
#main_nav ul li ul {
visibility: hidden;
position: absolute;
top: auto; /* Updated position to 'auto' and removed margin-top: 100% */
left: 0;
}
#main_nav ul ul li {
float: none;
width: 100%;
}
#main_nav ul li:hover ul,
#main_nav ul li:active ul,
#main_nav ul li:focus ul,
#main_nav ul li.thispage ul {
visibility: visible;
display: block;
}
I rewrote CSS which hopefully will be helpful to learn from as it is much simpler to understand as well as it fixes your problem.
Problem was that the sub menu items were with 100% width + 1px border on each side which is over 100% so it was overflowing.
Here is the link to JS Fiddle example with fix: http://jsfiddle.net/MartinTale/69gDQ/3/
Here is the new css:
#main_nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#main_nav ul {
width: 100%;
}
#main_nav li {
background-color: #4d4d4d;
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
#main_nav > ul > li {
float: left;
width: 20%;
}
#main_nav ul ul {
display: none;
}
#main_nav ul li:hover ul {
display: inline-block;
}
#main_nav a {
text-align: center;
text-decoration: none;
color: #FFF;
text-transform: uppercase;
display: inline-block;
width: 100%;
border-left: 1px solid #999999;
border-bottom: 1px solid #999999;
border-right: 1px solid #999999;
}
#main_nav ul li ul a {
border-left: 0;
border-right: 0;
}
#main_nav a:hover,
#main_nav a:active,
#main_nav a:focus,
#main_nav a.thispage {
background: #666;
color: #09F;
}

Resources