On Hover Menu List Items Disalign - html

I am using simple HTML and CSS to create horizontal menu using unordered list.
This is HTML & CSS code:
.nav_bar{
margin-left: 700px;
margin-top: 40px;
position: absolute;
}
.nav_bar ul{
list-style-type: none;
}
.nav_bar ul li{
display: inline-block;
text-align: center;
float: left;
}
.nav_bar ul li a{
text-decoration: none;
padding: 12px;
margin: 8px;
font-size: 20px;
color: #fff;
}
.nav_bar ul li a::after{
content: '';
display: inline-block;
width: 0px;
height: 4px;
background: #ff6600;
transition: width .4s;
}
.nav_bar ul li a:hover::after{
width: 100%;
}
<div class="nav_bar">
<ul>
<li>Services</li>
<li>Solution</li>
<li>Support</li>
<li>Partners</li>
<li>Contacts</li>
</ul>
</div>
I don't know where is the problem and why it is occurring?
Please help me out with good reason..

Ive fixed your code and ive got something like this.
.nav_bar ul li a{
text-decoration: none;
padding: 12px;
margin: 8px;
font-size: 20px;
color: orange;
position: relative;
}
.nav_bar ul li a::after{
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: auto;
height: 4px;
background: #ff6600;
transition: width .4s;
width: 0;
}
the problem is your after element is displayed inline-block so it rendered inline with your achor tag. and since your achor tag doesnt have enough width to display the ::after inline, your ::after element wrapped after your anchor tag.
see this: https://jsfiddle.net/pm68Lzmv/

Try this:
Add position:absolute; to :after selector for a tag
Remove margin-left from .nav_bar and add right:0
.nav_bar{
margin-top: 40px;
position: absolute;
right:0;
}
.nav_bar ul{
list-style-type: none;
}
.nav_bar ul li{
display: inline-block;
text-align: center;
float: left;
}
.nav_bar ul li a{
text-decoration: none;
padding: 12px;
margin: 0;
font-size: 20px;
color: #aaa;
display:block;
position:relative;
}
.nav_bar ul li a::after{
content: '';
display: inline-block;
width: 0px;
height: 4px;
background: #ff6600;
transition: width .4s;
position:absolute;
left:50%;
bottom:0;
transform: translateX(-50%);
}
.nav_bar ul li a:hover::after{
width: 100%;
}
<div class="nav_bar">
<ul>
<li>Services</li>
<li>Solution</li>
<li>Support</li>
<li>Partners</li>
<li>Contacts</li>
</ul>
</div>

Remove .nav_bar{ margin-left:0px}
Add .nav_bar ul li a position:relative;
add .nav_bar ul li a:after position:absolute;
.nav_bar ul{
list-style-type: none;
}
.nav_bar ul li{
display: inline-block;
text-align: center;
}
.nav_bar ul li a{
text-decoration: none;
padding: 12px;
margin: 0;
font-size: 20px;
color: #aaa;
display:block;
position:relative;
}
.nav_bar ul li a::after{
content: '';
display: inline-block;
width: 0px;
height: 4px;
background: #ff6600;
transition: width .4s;
position:absolute;
left:50%;
bottom:0;
transform: translateX(-50%);
}
.nav_bar ul li a:hover::after{
width: 100%;
}
<div class="nav_bar">
<ul>
<li>Services</li>
<li>Solution</li>
<li>Support</li>
<li>Partners</li>
<li>Contacts</li>
</ul>
</div>

Related

How to hover underline start from center instead of left?

I have a ul list and there i have given hover effect using :after this is working fine on hover, but now i want to it will be start from center instead of left.
My Code:
ul.my-list{ margin: 20px; padding: 0px; width: 200px;}
ul.my-list li{ list-style: none; position: relative; display: inline;}
ul.my-list li a{ color:#333; text-decoration: none;}
ul.my-list li:after{ content: ''; position: absolute; left: 0px; bottom: -2px; width:0px; height: 2px; background: #333; transition: all 0.45s;}
ul.my-list li:hover:after{ width: 100%;}
ul.my-list li a:hover{ text-decoration: none;}
<ul class="my-list">
<li>Welcome to my website</li>
</ul>
Quick solution:
Move the original position to left:50% and then, on hover, move it to left:0.
ul.my-list {
margin: 20px;
padding: 0px;
width: 200px;
}
ul.my-list li {
list-style: none;
position: relative;
display: inline;
}
ul.my-list li a {
color: #333;
text-decoration: none;
}
ul.my-list li:after {
content: '';
position: absolute;
left: 50%;
bottom: -2px;
width: 0px;
height: 2px;
background: #333;
transition: all 0.45s;
}
ul.my-list li:hover:after {
width: 100%;
left: 0;
}
ul.my-list li a:hover {
text-decoration: none;
}
<ul class="my-list">
<li>Welcome to my website</li>
</ul>
You can simplify your code using background like below
ul.my-list {
margin: 20px;
padding: 0px;
width: 200px;
}
ul.my-list li {
list-style: none;
display: inline-block;
padding-bottom:2px; /*the space for the gradient*/
background: linear-gradient(#333,#333) center bottom; /*OR bottom right OR bottom left*/
background-size: 0% 2px; /*width:0% height:2px*/
background-repeat:no-repeat; /* Don't repeat !!*/
transition: all 0.45s;
}
ul.my-list li a {
color: #333;
text-decoration: none;
}
ul.my-list li:hover {
background-size: 100% 2px; /*width:100% height:2px*/
}
<ul class="my-list">
<li>Welcome to my website</li>
</ul>
This is simple, you call the element after left 50% that means this it's the goon left to the middle when you hover the element after the width 100% and left 0, you already added some transition So, it looks middle to left and right. here the code;
ul.my-list{ margin: 20px; padding: 0px; width: 200px;}
ul.my-list li{ list-style: none; position: relative; display: inline;}
ul.my-list li a{ color:#333; text-decoration: none;}
ul.my-list li:after{
content: '';
position: absolute;
left: 50%; /* change this code 0 to 50%*/
bottom: -2px;
width:0px;
height: 2px;
background: #333;
transition: all 0.45s;
}
ul.my-list.rtl li:after { right: 0; left: inherit; }
ul.my-list li:hover:after{ left:0; width: 100%;} /* add poperty left 0 */
ul.my-list li a:hover{ text-decoration: none;}
<ul class="my-list">
<li>Welcome to my website</li>
</ul>
<h2>left start and end right</h2>
<ul class="my-list rtl">
<li>Welcome to my website</li>
</ul>
= = =
Thank you
= = =

how to display a dropdown ul two per row

I have a Nav with some unordered elements displayed horizontally and then I have a submenu from one of those elements of the nav, so far I'm displaying all the elements inline but I would like to display them side by side, just two of them per line.
How it actually looks:
And how I want it to be:
Just two columns displaying elements side by side, aligned to left side (of 50% width each side).
But I can't get it done, here's what I got so far
HTML
<nav id="menu">
<ul>
<li class="menu1">HOME</li>
<li class="left">NEWS</li>
<li class="left">VIDEOS</li>
<li class="left">STYLE</li>
<li class="left">BEAUTY</li>
<li class="left">MOMS</li>
<li class="left">ENTERTAINMENT</li>
<li class="left">PETS</li>
<li class="left">NEWS
<ul>
<li>Content1</li>
<li>Content2</li>
<li>Content3</li>
<li>Content4</li>
<li>Content5</li>
<li>Content6</li>
<li>Content7</li>
<li>Content8</li>
</ul>
</li>
</nav>
CSS
#menu {
position: absolute;
left:80px;
top:50%;
transform: translate(0%,-50%);
-webkit-transform: translate(0%,-50%);
}
#menu ul {
list-style:none;
position:relative;
float:left;
margin:0;
padding:0;
top:50%;
}
#menu ul li {
display: inline;
position: relative;
}
#menu ul li a {
color: #fff;
text-decoration: none;
font-family: 'Cabin', sans-serif;
background-color: ;
position: relative;
padding-top: 12px;
padding-bottom: 10px;
padding-right: 10px;
padding-left: 10px;
transition: background-color 0.2s ease-in-out;
}
#menu ul li a.news {
color:#ec008c;
transition: color 0.2s ease-in-out;
}
#menu ul li a:hover.news {
color: #fff;
}
#menu ul li a:hover {
background-color: #ec008c;
text-decoration: none;
border-bottom: 2px solid #bf1b33;
color: #fff;
}
#menu ul ul
{
display:none;
position:absolute;
top:100%;
right: 0%;
margin-left:0px;
text-align: center;
width: 350px;
line-height: 60px;
margin-top:12px;
background-color: #243641;
}
#menu ul ul.longer {
width: 150px;
}
#menu ul ul li
{
float:none;
width:100%;
background-color: ;
}
#menu ul ul a
{
line-height: 0px;
padding:0px 5px;
width: 100%;
background-color: ;
}
#menu ul li:hover > ul
{
display:block;
}
You can do something like this :
#menu ul ul li
{
float: left;
width: 50%;
}
See working demo here
You can use display: flex on the last ul and set a flex-basis width on the children (li). See my example below.
#menu ul li:hover > ul {
display: flex;
flex-flow: row wrap;
}
#menu ul ul li {
flex-basis: 50%;
}
This is all the extra code that's needed. I also fixed your code. because the <ul> didn't have closed tag (</ul>).
#menu {
position: absolute;
left: 80px;
top: 50%;
transform: translate(0%, -50%);
-webkit-transform: translate(0%, -50%);
}
#menu ul {
list-style: none;
position: relative;
float: left;
margin: 0;
padding: 0;
top: 50%;
}
#menu ul li {
display: inline;
position: relative;
}
#menu ul li a {
color: #fff;
text-decoration: none;
font-family: 'Cabin', sans-serif;
background-color: ;
position: relative;
padding-top: 12px;
padding-bottom: 10px;
padding-right: 10px;
padding-left: 10px;
transition: background-color 0.2s ease-in-out;
}
#menu ul li a.news {
color: #ec008c;
transition: color 0.2s ease-in-out;
}
#menu ul li a:hover.news {
color: #fff;
}
#menu ul li a:hover {
background-color: #ec008c;
text-decoration: none;
border-bottom: 2px solid #bf1b33;
color: #fff;
}
#menu ul ul {
display: none;
position: absolute;
top: 100%;
right: 0%;
margin-left: 0px;
text-align: center;
width: 350px;
line-height: 60px;
margin-top: 12px;
background-color: #243641;
}
#menu ul ul.longer {
width: 150px;
}
#menu ul ul li {
float: none;
width: 100%;
background-color: ;
}
#menu ul ul a {
line-height: 0px;
padding: 0px 5px;
width: 100%;
background-color: ;
}
#menu ul li:hover > ul {
display: flex;
flex-flow: row wrap;
}
#menu ul ul li {
flex-basis: 50%;
}
<nav id="menu">
<ul>
<li class="menu1">HOME</li>
<li class="left">NEWS</li>
<li class="left">VIDEOS</li>
<li class="left">STYLE</li>
<li class="left">BEAUTY</li>
<li class="left">MOMS</li>
<li class="left">ENTERTAINMENT</li>
<li class="left">PETS</li>
<li class="left">NEWS
<ul>
<li>Content1</li>
<li>Content2</li>
<li>Content3</li>
<li>Content4</li>
<li>Content5</li>
<li>Content6</li>
<li>Content7</li>
<li>Content8</li>
</ul>
</li>
</ul>
</nav>
You should use display: inline-block; width width: 50% on #menu ul ul li elements:
#menu ul ul {
display:none;
position:absolute;
top:100%;
right: 0%;
margin-left:0px;
text-align: center;
width: 350px;
line-height: 60px;
margin-top:12px;
background-color: #243641;
font-size: 0; /* white spaces fix */
}
#menu ul ul li {
font-size: 1rem; /* white spaces fix */
float: none;
width: 50%;
display: inline-block;
background-color: ;
}
#menu ul ul a {
display: block;
padding: 0px 5px;
width: 100%;
background-color: ;
}
JSfiddle here.
This might be useful for your needs.
I don't know if you are using any framework or not, but this should work for you :)
http://alijafarian.com/bootstrap-multi-column-dropdown-menu/

Resize text + image in proportion to nav bar when zooming

When I zoom my website the logo and text tend to not resize with the same proportionals as the div itself. The div is set up with % in the css to appear as the same size all the time. How do I make them resize equal when zooming?
I've tried to set the font size in %, but that doesn't work. The image is already the perfect size so I haven't resized that in the css.
Live example on the jsFiddle
HTML:
<div id=nav>
<div id="logo">
<img src="50.png">
</div>
<div id="menu">
<ul>
<li>Home</li>
<li>Music</li>
<li>Spotlight</li>
<li>Blog</li>
<li>What is ?</li>
</ul>
</div>
</div>
CSS:
#logo{
position: absolute;
left: 10px;
top: -2px;
}
#nav{
height: 7%;
background-color: #fbfbfb;
list-style-type: none;
position: fixed;
z-index: 100;
top: 0px;
width: 100%;
left: 0%;
border-bottom: 1px solid;
border-color: #02ddfe;
}
#menu{
width: 960px;
margin: 0 auto;
text-align: left;
position: fixed;
left: 2%;
font-size: 100%;
top: -2%;
}
#menu ul{
list-style-type: none;
text-align: center;
vertical-align: middle;
line-height: 47px;
position: absolute;
}
#menu ul ul{
display: none;
}
#menu ul a{
color: #bbbbbb;
text-decoration: none;
-webkit-transition: color 0.4s;
-moz-transition: color 0.4s;
transition: color 0.4s;
}
#menu ul li{
display: inline-block;
text-align: center;
}
#menu ul li a,visited{
color: #bbbbbb;
display: block;
padding: 0px;
padding-left: 20px;
text-decoration: none;
}
#menu ul li a:hover{
color: #4ebbe8;
text-decoration: none;
}
#menu ul li:hover ul{
display: block;
}
#menu ul ul{
background-color: #ffffff;
position: absolute;
display: none;
margin: 0px;
padding: 0px;
}
try this one : http://jsfiddle.net/rfv2h3m5/1/
code change :
HTML:
<div id="menu">
<ul>
<li>Home</li>
<li>Music</li>
<li>Spotlight</li>
<li>Blog</li>
<li>What is ?</li>
</ul>
</div>
css:
#logo{
position: absolute;
left: 10px;
top: 10px;
background:url("http://www.fnordware.com/superpng/pnggrad8rgb.png") no-repeat;
width:8%;
height:72%;
background-size: 100%;
}
#nav{
height: 40%;
background-color: #fbfbfb;
list-style-type: none;
position: fixed;
z-index: 100;
top: 0px;
width: 100%;
left: 0%;
border-bottom: 1px solid;
border-color: #02ddfe;
font-size : 100%;
}
#menu{
width: 90%;
margin: 0 auto;
text-align: left;
position: fixed;
left: 2%;
font-size: 100%;
top: -2%;
}
#menu ul{
list-style-type: none;
text-align: center;
vertical-align: middle;
}
#menu ul ul{
display: none;
}
#menu ul a{
color: #bbbbbb;
text-decoration: none;
-webkit-transition: color 0.4s;
-moz-transition: color 0.4s;
transition: color 0.4s;
}
#menu ul li{
display: inline-block;
text-align: center;
}
#menu ul li a,visited{
color: #bbbbbb;
display: block;
padding: 0px;
padding-left: 20px;
text-decoration: none;
}
#menu ul li a:hover{
color: #4ebbe8;
text-decoration: none;
}
#menu ul li:hover ul{
display: block;
}
#menu ul ul{
background-color: #ffffff;
position: absolute;
display: none;
margin: 0px;
padding: 0px;
}

css and html drop down menu

hey i was learning how to use the drop down menu with css, but i faced two problems:
The length of my first drop down menu changes, even though i kept playing with their percentages.
I am not able to bring my second drop down menu, i guess i don't know how to call the second drop down menu in css even though i gave it a different class name.
Here is the HTML code just for the drop down menu:
<div class="list">
<ul class="style">
<li class="international">International
<ul class="sub1">
<li class> Top 10</li>
<li> All</li>
</ul>
</li>
<li class="pop">Pop
<ul class="sub1" >
<li> Top 10</li>
<li> All</li>
</ul>
</li>
<li class="electronic">Electronic
<ul class="sub1">
<li> Top 10</li>
<li> All
<ul class="sub2">
<li> English</li>
<li> European</li>
<li> International</li>
</ul>
</li>
</ul>
</li>
</div>
and here is the CSS code:
div ul li {
display:inline-block;
background-color:#B2B28F;
float:right;
text-align: center;
width: 22%;
position: relative;
z-index: 1;
bottom: 19px;
padding-top: 5px;
font-size: 18px;
padding-bottom: 3px;
font-weight: bold;
font-family: harrington;
margin-right: 12px;
border-bottom:5px;
margin-bottom: 10px;
text-align: center;
margin-top: 2px;
}
div ul li a {
display: block;
height: 30px;
text-align: center;
border-bottom:5px;
position: relative;
font-size: 20;
z-index: 1;
margin-top: 2px;
}
.sub1 li {
display: none;
position:relative;
width:100%;
height: 20px;
margin-bottom:-8px;
margin-top:12px ;
float: right;
font-size: 17;
margin-right: 4px;
padding: 2px;
text-align: center;
left:-20px;
}
.sub1 li a {
text-align: left;
margin-right: 15px;
}
.sub2 li {
position: relative;
left: 15px;
top: -30px;
width: 100%;
text-align: left;
margin-top: -3px;
margin-bottom: 4px;
display: none;
float: left;
}
div ul li:hover ul li{
display: block;
position: absolute;
top: 27px;
float: left;
width: 97%;
left: 0px;
height: 23px;
border-top: 5px;
text-align: center;
}
div ul li :hover ul li ul li {
display: block;
position: absolute;
text-align: center;
}
a:link {
text-decoration: none;
}
a:visited {
color:#520029;
}
a:hover {
color: #293D66;
}
also any comments on how i did would be appreciated!
Hope you like this..
Just made some changes on your html and css.
HTML:
<div class="nav">
<ul>
<li>International
<ul>
<li> Top 10</li>
<li> All</li>
</ul>
</li>
<li>Pop
<ul>
<li> Top 10</li>
<li> All</li>
</ul>
</li>
<li>Electronic
<ul>
<li> Top 10</li>
<li> All
<ul>
<li> English</li>
<li> European</li>
<li> International</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
CSS:
.nav {
margin: 50px auto;
text-align: center;
}
.nav ul ul {
display: none;
}
.nav ul li:hover > ul {
display: block;
}
.nav ul {
background: #C0C0C0;
padding: 0 20px;
list-style: none;
position: relative;
display: inline-table;
}
.nav ul:after {
content: ""; clear: both; display: block;
}
.nav ul li {
float: left;
}
.nav ul li:hover {
background: #4b545f;
}
.nav ul li:hover a {
color: #fff;
}
.nav ul li a {
display: block; padding: 10px 20px;
color: #757575; text-decoration: none;
}
.nav ul ul {
background: #5f6975; padding: 0;
position: absolute; top: 100%;
}
.nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a; position: relative;
}
.nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
.nav ul ul li a:hover {
background: #4b545f;
}
.nav ul ul ul {
position: absolute; left: 100%; top:0;
}
Also Here is the fiddle, Check this working here
I would recommend not using absolute positioning and floats to elements that don't need it..
regarding your second sub, I got it working in this example..
div > ul > li {
display:inline-block;
background-color:#B2B28F;
float:right;
text-align: center;
width: 22%;
position: relative;
z-index: 1;
bottom: 19px;
padding-top: 5px;
font-size: 18px;
padding-bottom: 3px;
font-weight: bold;
font-family: harrington;
margin-right: 12px;
border-bottom:5px;
margin-bottom: 10px;
text-align: center;
margin-top: 2px;
}
div ul li a {
display: block;
text-align: center;
padding:5px 0;
position: relative;
font-size: 20px;
z-index: 1;
color:#212121;
padding-left:10px; box-sizing:border-box;
}
ul { padding:0;}
ul li { list-style:none;}
.sub1 { display:none; width:100%;}
.sub1 li {
position:relative;
width:100%;
clear:both;
font-size: 17px;
text-align: center;
}
.sub1 li a {
text-align: left;
}
.sub2 { display:none; position: relative; background:#B2B28F;}
.sub2 li {
width: 100%;
text-align: left;
margin-bottom: 4px;
padding-left:20px;
box-sizing:border-box;
}
.sub2 li a { font-size:14px;}
div ul li:hover ul li{
width: 100%;
left: 0px;
border-top: 5px solid;
text-align: center;
}
div ul li:hover > ._sub { display:block;}
a:link {
text-decoration: none;
}
a:visited {
color:#520029;
}
a:hover {
color: #293D66;
}
http://jsfiddle.net/2mSzr/
notice I make more specific rules with the '>' option in css, so the styling rules will not
apply to the wrong elements..
Also in the HTML I've added _sub class to all sub menus, and changed the behavior so the display:none/block will be on the actual ul._sub elements and not on their li's.. it just
makes more sense..
go over the example above, let me know if you have any questions.

Need make pure css menu with 3 level

I make pure css menu with 2 levels .But now I need to make it 3 levels .I tried many time but not working for me . here is the jsfiddle .
I don't need any jquery code, just pure css .
CSS
#menu {
width: 980px;
height: 30px;
float: left;
border-top: dashed 1px #d8d8d8;
margin-left: 7px;
}
#menu ul.Mainmenu {
width: 996px;
margin: 0px;
padding: 0px;
margin-top: 10px;
}
#menu ul.Mainmenu li {
float: left;
list-style: none;
margin-right: 20px;
font-family: Verdana, Geneva, sans-serif;
font-size: 14px;
color: #860300;
margin-right: 16px\9; /* IE8 and below */
position: relative;
height: 30px;
}
#menu ul.Mainmenu li a {
text-decoration: none;
font-family: Verdana, Geneva, sans-serif;
font-size: 13px;
color: #860300;
}
ul li ul {
padding: 0;
position: absolute;
top: 25px;
left: -10px;
width: 190px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
z-index: 100000;
width: 200px;
background-color: #FFF;
padding: 7px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
ul li ul li {
color: #fff;
float: left;
width: 190px;
height: auto !important;
min-height: 20px;
margin-bottom: 9px;
line-height: 18px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
padding-top: 3px;
padding-left: 3px;
}
ul li ul li a {
color: #fff;
font-size: 12px !important;
}
ul li ul li:hover {
background: #820B06;
color: #FFF;
}
ul li ul li:hover a {
color: #FFF !important;
}
ul li:hover ul {
opacity: 1;
visibility: visible;
}
Thanks guys
See this example
css
#nav ul{
margin:0;
padding:0;
list-style:none;
}
#nav ul li{
margin:0;
padding:10px 20px;
position:relative;
height:20px;
line-height:20px;
background-color:#EEE;
}
#nav > ul > li {
float: left;
height:30px;
line-height:30px;
background-color:#CCC;
}
#nav li > ul{
visibility:hidden;
width:200px;
position: absolute;
top:0px;
left:200px;
border-left:1px solid #000;
}
#nav > ul > li > ul{
top:50px;
left:0;
}
#nav li:hover{
background-color:#999;
}
#nav li:hover > ul{
visibility:visible;
}
html
<div id="nav">
<ul>
<li>Level 1
<ul>
<li>Level 2-1</li>
<li>Level 2-2
<ul>
<li>Level 3-1</li>
<li>Level 3-2</li>
</ul>
</li>
</ul>
</li>
</ul>
Here i added sample CSS Menu with level 3. Please check and let me know. Hope it should helpful for you. Thanks.
.third-level-menu
{
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li
{
height: 30px;
background: #999999;
}
.third-level-menu > li:hover { background: #CCCCCC; }
.second-level-menu
{
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu > li
{
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:hover { background: #CCCCCC; }
.top-level-menu
{
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li
{
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.top-level-menu > li:hover { background: #CCCCCC; }
.top-level-menu li:hover > ul
{
/* On hover, display the next level's menu */
display: inline;
}
/* Menu Link Styles */
.top-level-menu a /* Apply to all links inside the multi-level menu */
{
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
/* Make the link cover the entire list item-container */
display: block;
line-height: 30px;
}
.top-level-menu a:hover { color: #000000; }
<ul class="top-level-menu">
<li>About</li>
<li>Services</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago</li>
<li>Los Angeles</li>
<li>
New York
<ul class="third-level-menu">
<li>Information</li>
<li>Book a Meeting</li>
<li>Testimonials</li>
<li>Jobs</li>
</ul>
</li>
<li>Seattle</li>
</ul>
</li>
<li>Contact</li>
</ul>
I have also put together a live demo here http://jsfiddle.net/4ScFz/400/ that's available to play with.