Responsive Menu style using CSS Display the dropdown on hover - css

So I have looked at lots of other examples and I still can't figure out what I am missing. The menu works great except when I look at it in phone mode the menu does not drop on the hover. Can you help?
THE CSS code
/*Strip the ul of padding and list styling*/
#menu ul {
list-style: none;
width: 100%;
margin: 0;
padding: 0;
float: left;
background: #645565;
font-size: 1em;
}
/*Create a horizontal list with spacing*/
#menu li {
float: left;
position: relative;
display: inline-block;
}
/*Style for menu link*/
#menu li a {
display: block;
line-height: 3em;
font-family: Trebuchet MS, Verdana, Arial, sans-serif;
font-size: 0.95em;
color: #BFA877;
text-decoration: none;
padding: 0 0.9em;
}
/*Hover over text upper*/
#menu li:hover > a {
color: #FFF6D6;
}
/*Displays dropdown*/
#menu ul li:hover > ul {
display: block;
}
/*Hide dropdown links until they are needed*/
#menu li ul {
display: none;
position: absolute;
}
/*Display the dropdown on hover*/
.dropdown:hover .dropdown-content {
display: block;
}
/*Style "show menu' label button and hide it by default*/
.dropdown{
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-decoration: none;
color: #FFF6D6;
background: #645565;
text-align: center;
padding: 10px 0;
display: none;
z-index: 1;
}
/*Hide checkbox*/
input[type=checkbox] {
display: none;
}
/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu {
display: block;
}
/*==========MOBILE===========*/
/*Responsive Styles*/
#media screen and (max-width: 768px){
/*Make dropdown links appear inline*/
#menu ul {
position: static;
display: none;
}
/*Create vertical spacing*/
#menu li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
#menu ul li, li a {
width: 100%;
}
/*Display "show menu" link*/
.dropdown {
display: block;
}
}
THE HTML code
<div id="container">
<label for="dropdown" class="dropdown">Show Menu</label>
<input type="checkbox" id="dropdown" role="button">
<div id="menu">
<ul>
<li>Home</li>
<li>
Massage & Spa
<ul class="dropdown-content">
<li>Massage Treatment</li>
<li>Balancing Energies</li>
<li>Signature Massage Treatment</li>
<li>Thai Massage</li>
<li>Signature Spa Treatment</li>
<li>List of Treatments & Rates</li>
</ul>
</li>
<li>Well Being</li>
<li>
About Us
<ul class="dropdown-content">
<li>Richard Davenport</li>
<li>Katrine Dannieu</li>
<li>Beth Drake</li>
<li>Daniel</li>
<li>Ciciely</li>
<li>Ish</li>
<li>Elizabeth</li>
<li>Tyler</li>
<li>Julia</li>
<li>Asley</li>
<li>Sandra</li>
</ul>
</li>
<li>
To Know
<ul class="dropdown-content">
<li>How to prepare for your massage</li>
<li>The right pressure during your Massage</li>
<li>How often should you get a massage?</li>
<li>Here is why you should book your next appointment ASAP</li>
<li>What is Rieki Who can learn</li>
<li>Dr. Oz and the healing power of Reiki</li>
</ul>
</li>
<li>Location</li><li>
Contact</li><li>
Calendar</li><li>
Events</li><li>
Links</li>
</ul>
</div>
</div><!-----End of container----->

Phones don't support the hover action!

Related

How can I make this menus dropdown items show vertical?

I made this horizontal menu, and everything was nice and good, until I realized that I can't make the submenus appear vertical, can someone help me?
Here is the menu code:
<div id="nav_custom">
<div id="nav_custom_wrapper"></div>
<ul>
<li>NEW ARRIVALS
</li>
<li>
SEQUIN DRESSES
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
</li><li>
BOHO DRESSES
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
</li><li>
MOD DRESSES
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
</li><li>
PSYCHEDELIC DRESSES
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
</li><li>
COATS & JACKETS
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
<li>
KIMONOS
<ul id="nav_custom_sub">
<li>AVAILABLE</li>
<li>EXAMPLES SOLD</li>
</ul>
</li>
</ul>
</div>
Here is the css that I have used:
#nav_custom {
text-decoration: none;
font-family: 'Source Sans Pro', sans-serif;
font-size: 14px;
font-style: normal;
font-variant: normal;
font-weight: 400;
line-height: 49px;
color: #000;
display: block;
padding: 10px;
width: 960px;
margin-left: -35px;
margin-right: auto;
text-align: center;
width: auto;
}
#nav_custom_wrapper {
width: 960px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#nav_custom ul{
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
#nav_custom ul li{
display: inline-block;
}
#nav_custom ul li:hover{
color: #000;
text-decoration: none;
}
#nav_custom ul li a,visited{
color: #BA7145;
padding: 15px;
text-decoration: none;
}
#nav_custom ul li a:hover{
color: #000;
text-decoration: none;
}
#nav_custom ul li:hover ul{
display: block;
}
#nav_custom ul ul{
display: none;
position: absolute;
margin-top: -25px;
margin-left: -50px;
text-align: center;
color: #4f4f4f;
}
Remove the inline-block on the #nav_custom ul li
See fiddle for working example: http://jsfiddle.net/Tv77g/
Inline-block works similarly to floats, which is why they were stacking left to right next to each other instead of one on top of each other.
I didn't go through to adjust your children. I don't know how the menu is supposed to display. Most likely the children (#nav_custom ul ul) would have the margins adjusted. You can remove text-align:center; on #nav_custom to make the menu completely left aligned.
To set this only on children, add
#nav_custom_sub li {
display: block !important;
}
This will override the inline-block for only the children (in the dropdown). You will have to adjust the margins to make them appear correctly.

How do I keep nested children (li) inline for my footer navigation?

I have a simple question. I'm trying to display the elements for "about" "general" and "social-buttons" classes within a nested unordered list. I want these to appear horizontal and inline with each other. I want them to be side by side basically, not vertical. If you can help me figure out which selector I need to add the 'display:inline' block, that would be much useful.
<div class="footer-container">
<div id="footer_menu">
<div id="footer-copy">
<li class="about-blurb">
<h3>Viral DNA</h3>
<ul>
<li>
<p>Virael Marketing is the leading digital marketing blog for the social web. We are a one-stop hub to help you learn from your viral marketing campaigns, offer tips & tricks, and build the best digital marketing teams.</p>
</li>
</ul>
<li class="General">
<h3>General</h3>
<ul>
<li><a class="button" href="#">Media</a></li>
<li><a class="button" href="#">Resources</a></li>
<li><a class="button" href="#">Blog</a></li>
<li><a class="button" href="#">Store</a></li>
<li><a class="button" href="#">Contact</a></li>
</ul>
<li class="social-icons">
<h3>Follow Virael</h3>
<ul>
<li>
<!--social media buttons go here-->
</li>
</ul>
</ul>
</div>
</div>
The CSS:
.footer-container {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
float: left;
text-align: left;
width: 828px;
text-transform: capitalize;
background-color: #4169E1;
color: #FFF;
position: relative;
bottom: 0;
left: 269px;
border-top: 10px solid #B0C4DE;
overflow: hidden;
z-index=-1000;
}
.footer-container h3 {
text-align:justify;
}
#footer_menu {
font-family: MyriadPro-Regular, 'Myriad Pro Regular', MyriadPro,'MyriadPro', Arial, sans-serif;
list-style-type:none;
z-index=-1000;
}
#footer_menu ul {
margin: 0px 30px;
padding: 10px 30px;
list-style-type:none;
text-decoration:none;
display:inline;
z-index=-1000;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
z-index=-100;
display:block;
color: white;
clear:both;
}
#footer_menu .about-blurb ul li {
width: 200px;
height: auto;
text-align:justify;
}
Replace your css with mine. Live example here
#footer_menu ul {
/* margin: 0px 30px; */
padding: 10px 30px;
list-style-type: none;
text-decoration: none;
display: inline;
}
#footer_menu ul li {
margin: 0 0;
padding: 5px 0;
display: inline-block;
color: white;
clear: both;
}
Remove margins from the ul and add inline-block to li

Dropdown menu not showing up on IE6 (Drupal, superfish)

I've been assigned to remake a Drupal website in which i have to implement a dropdown menu.
It works fine on IE8,Chrome,Firefox but not in IE6 (and most users of this site use IE6...)
The module is Superfish, here is some code:
<body class="homepage">
<div id="global">
<div id="header">
<div id="header-content">
<div class="fil-ariane">You are here : Home</div>
<div class="search">search stuff</div>
<div id="block-superfish-1"
class="block block-superfish contextual-links-region">
<div
class="contextual-links-wrapper contextual-links-processed">
<div class="content">
<ul id="superfish-1"
class="menu sf-menu sf-menu-menu-header sf-horizontal sf-style-sna_superfish sf-total-items-3 sf-parent-items-1 sf-single-items-2 nav superfish-processed">
<li id="menu-477-1"
class="first odd sf-item-1 sf-depth-1 sf-no-children">
<li id="menu-501-1"
class="middle even sf-item-2 sf-depth-1 sf-no-children">
<li id="menu-983-1"
class="last odd sf-item-3 sf-depth-1 sf-total-children-3 sf-parent-children-0 sf-single-children-3 menuparent">
<a class="sf-depth-1 menuparent"
href="LIEN_homepage/#">USEFUL LINKS</a>
<ul>
<li id="menu-986-1"
class="first odd sf-item-1 sf-depth-2 sf-no-children">
<a class="sf-depth-2" href="LINK1">text_link1</a>
</li>
<li id="menu-985-1"
class="middle even sf-item-2 sf-depth-2 sf-no-children">
<a class="sf-depth-2" href="LINK2">text_link2</a>
</li>
<li id="menu-984-1"
class="last odd sf-item-3 sf-depth-2 sf-no-children">
<a class="sf-depth-2" href="LINK3">text_link3</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
And here's the CSS:
body{
width:100%;
height:100%;
font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size:11px;
color:#333333;
background-color:#e2dad0;
}
.homepage{background-color:#ffffff;}
#global{
width:100%;
height:100%;
margin:0 auto;
}
#header{
width:100%;
min-width:880px;
height:29px;
max-height:30px;
background:#706e67;
color:#ffffff;
position:fixed;
z-index:10;
top:0px;
}
#header a{font-weight:bold;color:#ffffff;text-decoration:none}
#header a:hover{text-decoration:none;}
#header-content{width:100%;margin:0 auto;}
#header-content .fil-ariane{float:left;padding-top:9px;padding-left:8px;}
#header-content .nav{float:right;margin-right:129px !important;margin-right:67px;}
#header-content .nav ul{display:inline;}
#header-content .nav ul li{display:inline;}
#header-content .nav a,span{vertical-align:middle;font-weight:bold;}
.link-rss{width:14px;height:14px;background:url("../img/common/pictos/rss.gif") left top no-repeat;overflow:hidden;text-indent:-500px;display: inline-block;vertical-align:middle}
#header-content .search{float:right;width:125px;padding-top:2px;overflow:hidden;position:absolute;right:2px;}
#header-content .search form .content{width:123px;height:24px;background:url("../img/common/header/bkgInputText.gif") right top no-repeat;}
#header-content .search .input-submit{width:25px;height:24px;background:url("../img/common/header/btSearch.gif") left top no-repeat;overflow:hidden;margin:0;padding:0;border:0 none;text-indent:-50px;letter-spacing:+100px;vertical-align:top;cursor:pointer}
#header-content .search .input-text{padding:0 0 0 5px;border:0 none;width:90px;height:24px;line-height:24px;color:#826041;vertical-align:baseline;font-size:10px;background-color:#f1f1f0;}
OTHER CSS:
.sf-menu span{
display:block;
position:relative;
}
.sf-menu.sf-style-sna_superfish {
float: left;
margin-bottom: 1em;
padding: 0;
}
.sf-menu.sf-style-sna_superfish.sf-navbar {
width: 100%;
}
.sf-menu.sf-style-sna_superfish ul {
padding-left: 0;
}
.sf-menu.sf-style-sna_superfish a, .sf-menu.sf-style-sna_superfish span {
padding: 0.75em 1em;
}
.sf-menu.sf-style-sna_superfish a.sf-with-ul {
padding-right: 2.25em;
}
.sf-menu.sf-style-sna_superfish.rtl a.sf-with-ul {
padding-left: 2.25em;
padding-right: 1em;
}
.sf-menu.sf-style-sna_superfish.sf-navbar a {
border: 0;
}
.sf-menu.sf-style-sna_superfish span.sf-description {
color: #f1f1f1;
display: block;
font-size: 0.8em;
line-height: 1.5em;
margin: 5px 0 0 5px;
padding: 0;
}
.sf-menu.sf-style-sna_superfish li,
.sf-menu.sf-style-sna_superfish li li,
.sf-menu.sf-style-sna_superfish li li li,
.sf-menu.sf-style-sna_superfish.sf-navbar {
margin:0px;
background: #706E67;
}
.sf-menu.sf-style-sna_superfish li:hover,
.sf-menu.sf-style-sna_superfish li.sfHover,
.sf-menu.sf-style-sna_superfish li.active a,
.sf-menu.sf-style-sna_superfish a:focus,
.sf-menu.sf-style-sna_superfish a:hover,
.sf-menu.sf-style-sna_superfish a:active,
.sf-depth-1.menuparent.nolink span:hover,
.sf-menu.sf-style-sna_superfish.sf-navbar li li {
display:block;
float:left;
background: #666459;
color: #ffffff;
}
.sf-menu.sf-style-sna_superfish.sf-navbar li ul {
background-color: #008ad2;
}
.sf-menu.sf-style-sna_superfish.sf-navbar li ul li ul {
background-color: transparent;
}
.sf-menu.sf-style-sna_superfish ul.sf-megamenu li.sf-megamenu-wrapper ol,
.sf-menu.sf-style-sna_superfish ul.sf-megamenu li.sf-megamenu-wrapper ol li {
margin: 0;
padding: 0;
}
.sf-menu.sf-style-sna_superfish ul.sf-megamenu li.sf-megamenu-wrapper a.menuparent {
font-weight: bold;
}
.sf-menu.sf-style-sna_superfish ul.sf-megamenu li.sf-megamenu-wrapper ol li.sf-megamenu-column {
display: inline;
float: left;
width: 12em;
}
.sf-menu.sf-style-sna_superfish.rtl ul.sf-megamenu li.sf-megamenu-wrapper ol li.sf-megamenu-column {
float: right;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-1 ul.sf-megamenu {
width: 12em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-2 ul.sf-megamenu {
width: 24em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-3 ul.sf-megamenu {
width: 36em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-4 ul.sf-megamenu {
width: 48em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-5 ul.sf-megamenu {
width: 60em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-6 ul.sf-megamenu {
width: 72em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-7 ul.sf-megamenu {
width: 84em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-8 ul.sf-megamenu {
width: 96em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-9 ul.sf-megamenu {
width: 108em;
}
.sf-menu.sf-style-sna_superfish li.sf-parent-children-10 ul.sf-megamenu {
width: 120em;
}
Not everything's useful i guess but i found some solutions in which the style (properties 'position','display') of the nearby divs/classes was important.
My questions are:
how can i make that menu appear on IE6 ? Is it only a matter of styling? Do i have to make some javascript ?
i'm assuming superfish is a spin off of suckerfish...suckerfish required javascript for ie6 support, so i'll assume that you need the same. of you go to superfish documentation page, there are scripts listed as included with the module. i would look to into those. essentially, you need ie6 to fake hover on the elements, to show your menu

Nav bar submenu container: How to cope with long list-item overflow by wrapping?

I have a hosted blog and I'm modifying templates, however the code for adding submenus to the nav bar is straight out of this great tutorial:
http://www.devinrolsen.com/pure-css-horizontal-menu/
I also read this answer to the question on Stackoverflow http://bit.ly/16KQN0M
But if it's a matter of clearing a float, I can't see where to put "clear: both;" in the HTML (at least, nothing I've tried has worked).
And changing #dropnav li li to display: block; doesn't work either. There must be something I'm missing ...
Here is the CSS. The classes at the top are related to the template but I'll leave them in as they might be relevant.
<style type="text/css">
/* Derived from http://www.devinrolsen.com/pure-css-horizontal-menu/ */
#pagebody { position: inherit !important; width: 100%; }
#pagebody-inner { position: inherit !important; width: 100%; }
#alpha, #beta, #gamma, #delta {
display: inline;
position: inherit !important;
float: left;
min-height: 0px;
}
#dropnav
{height:31px;}
#dropnav ul
{margin:0px; padding:0px;}
#dropnav ul li
{display:inline; float:left; list-style:none; position: relative; height:31px;
width: 175px; }
#dropnav li a
{color:#efe1ca; font-family:'Roboto Condensed', sans-serif; font-weight:400;
font-size:12px; }
#dropnav li a:hover
{color:#fff; text-decoration: none;}
#dropnav li ul
{margin: 0px; padding: 0px; display: none; position: absolute; z-index: 99; top:
31px; background-color: #f6f3cb; width: 250px;}
#dropnav li:hover ul
{display:block; width:250px; }
#dropnav li li
{list-style:none; display:list-item; font-size:100%;}
#dropnav li li a
{color: #7a3535; text-decoration:underline; width: 250px; font-size: 16px; }
#dropnav li li a:hover
{color:#000000; text-decoration:none; }
li#main {padding: 0px;} /* Sets the padding of items in the main menu */
</style>
And HTML markup, with titles removed:
<div id="main">
<div id="dropnav">
<ul>
<li class="nav-list-item">-------
<ul id="subnav">
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
</ul>
</li>
<li class="nav-list-item">-------
<ul id="subnav">
<li style="width:180px;">-------</li>
<li style="width:180px;"><a href="">-------</li>
</ul>
</li>
</ul>
</div>
</div>

UL Dropdown Menu Problems

I have two problems with my dropdown menu, one involving links, the other involving IE7 issues. Code follows after questions, and in both instances, I'm trying to avoid javascript (a key part of the project)
I am successfully highlighting the text of the link when I hover, including some pixels above, below and left & right. However, the only part of the highlight that is clickable (i.e. where I can access a hyperlink) is where the text is, and I want to be able to have the entire highlight, padding and text, to be clickable. I've done it before, but I'm confused with the current code on how to fix it. Can anybody help me out?
Using the same dropdown, everything is working fine, except in IE7. Some IE7 users complained that once they highlighted the menu item and the dropdown occurs, they only get down to about the 2nd item before the dropdown disappears, and it does it for every dropdown. I know it's an issue with IE7, but I need to get a work around for it. Any help at all?
My CSS code:
ul { list-style: none; }
p { margin: 8px 0; }
ul.dropdown { list-style-type:none;height:24px; top:2px; padding:0px 0px 0px 0px;;margin:0px 0px 0 1px;vertical-align:bottom; color:#000000; position: relative; }
ul.dropdown a:hover { color: #000; }
ul.dropdown a:active { color: #ffa500; }
ul.dropdown li { float: left; position:relative; vertical-align:middle; background-position:0 -40px; padding: 2px 4px 5px 2px; margin-right:6px;}
ul.dropdown li a { display: block; padding: 0px 0px; color: #222; text-decoration:none; vertical-align:middle; width:100%;}
ul.dropdown li:last-child a { border-right: none; }
ul.dropdown li.hover,
ul.dropdown li:hover { background: #F3D673; color: black; position: relative; }
ul.dropdown li.hover a { color: black; }
ul.dropdown ul { width: 152px; visibility: hidden; position: absolute; top: 100%; left: -40px; z-index:60;}
ul.dropdown ul li { font-weight: normal; background: #ECEAD8; color: #000; width:100%;/*border-bottom: 1px solid #ccc;*/ float: none; }
ul.dropdown ul li.nohover { color: black; background: #ECEAD8; position:relative; }
ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; min-height:1.4em;}
ul.dropdown ul ul { left:72.7%;top: 0px; width:158px; z-index:50; display:inline-block;}
ul.dropdown li:hover > ul { visibility: visible; display:block; }
#arrowRight { float:right; margin-top:-11px;}
a.moreItems {background: url(/images/menu/arrow_r.gif) no-repeat right;}
Here is the HTML Code:
<!DOCTYPE HTML>
<html>
<head>
<title></title>
<link rel=stylesheet type="text/css" href="menustylesheet.css">
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" class="topmenu" bgcolor="##ECEAD8" nowrap>
<ul class="dropdown">
<li><b>Item 1</b> <img src="/images/menu/arrow_d.gif" border="0" height="7" width="7">
<ul>
<li><a class="moreItems" href="">Item 1-1</a>
<ul>
<li>Item 1-1-1</li>
</ul>
</li>
<li><a class="moreItems" href="">Item 1-2</a>
<ul>
<li>Item 1-2-1</li>
</ul>
</li>
<li>Item 1-3 <div style="vertical-align:middle;"><img src="/images/menu/arrow_r.gif" id="arrowRight" border="0"></div>
<ul>
<li>Item 1-3-1</li>
<li>Item 1-3-2</li>
</ul>
</li>
<li>Item 1-4</li>
<li>Item 1-5</li>
</ul>
</li>
</ul>
</td>
</tr>
<tr><td bgcolor="##c0c0c0" style="height:1px;"></td></tr>
</table>
</body>
</html>
I apologize if this has been answered before, but I hope someone can pinpoint where in the code I need to change or modify to make it work.
I have an answer to your first problem. When doing this kind of menu. I stay as far away from padding as I can. I find it easier just to use margins, but for starters lets look at a page I built for you:
http://www.albatrossfonts.com/stack/ulbuttons.html
I'll explain this code below.
Here is my HTML:
<div id="wrapper">
<ul class="dropdown">
<li>Button 1</li>
<li>Button 1</li>
<li>Button 1</li>
</ul>
</div>
And the CSS:
.dropdown
{
width: 200px;
display:block;
margin: 200px auto 0 auto;
list-style-type: none;
padding: 0;
}
.dropdown li
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 1px 0 0 0;
list-style-type: none;
padding: 0;
}
.dropdown li a:link, .dropdown li a:visited
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 0;
color: #ffffff;
background-color: #666666;
text-decoration: none;
text-indent: 12px;
line-height: 44px;
}
.dropdown li a:hover
{
background-color: #333333;
}
Notice that I declared a:link, instead of just a. I also declared a:visited since I want the visited state to be the same as the original state.
In the .dropdown entry, I simply defined a width for the list (ul) and made it display properly.
In the .dropdown li entry, I set the width and height of each list item, removed bullets, and set the display and float to make them display as a box. No padding. Just a box.
In the .dropdown li a:link, .dropdown li a:visited entry, what we are essentially doing is "filling" our list item boxes with a link, and it just so happens that we can define a link as a box as well. So I set the dimensions of the link to the exact same size as our li's (this is what makes the entire box clickable). Then set the display and float, and a background color, as well as a text color, or simply "color."
In order to get your text in the center, you should not use vertical-align. Use line-height, and set it to the same height as your li element. This will center your text in the box vertically.
To control where your text appears horizontally, set a text-indent property, use text-align. In this example, I used text-indent.
Finally, we define our a:hover state. It's important to remember that the only things you truly need to define here are any properties that actually change. In this case, the background color.
If you wanted to ad a state for the mouse down event, you could do something like:
.dropdown li a:active
{
background-color: #000000;
text-indent: 20px;
}
/////////// Edit////////////
Here's how you would use a single css styles for multiple menus or child menus.
html for 2 separate ul's:
<ul class="dropdown">
<li>Button 1</li>
<li>Button 1</li>
<li>Button 1</li>
</ul>
<ul class="dropdown">
<li>Button 1</li>
<li>Button 1</li>
<li>Button 1</li>
</ul>
CSS: (stays the same, because you assign both of them to the class "dropdown."
.dropdown
{
width: 200px;
display:block;
margin: 200px auto 0 auto;
list-style-type: none;
padding: 0;
}
.dropdown li
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 1px 0 0 0;
list-style-type: none;
padding: 0;
}
.dropdown li a:link, .dropdown li a:visited
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 0;
color: #ffffff;
background-color: #666666;
text-decoration: none;
text-indent: 12px;
line-height: 44px;
}
.dropdown li a:hover
{
background-color: #333333;
}
If you want to apply your styles for a child ul, like this:
<ul class="dropdown">
<li>Button 1
<ul>
<li><a href="#">subButton 1</li>
<li><a href="#">subButton 2</li>
<li><a href="#">subButton 3</li>
</ul>
</li>
<li>Button 1</li>
<li>Button 1</li>
</ul>
You simply append your styles to include the child ul and child ui li, as follows; where .dropdown actually represents your first ul. So .dropdown(ul) --> li (list item in "dropdown" unordered list) --> ul (ul inside dropdown li) --> li (li inside dropdown ul li ul)
Sorry if that sounds confusing, but in other words, if you didn't assign a class to your parent ul at all, it would be ul li ul li to access a list item inside a child list.
.dropdown, dropdown li ul
{
width: 200px;
display:block;
margin: 200px auto 0 auto;
list-style-type: none;
padding: 0;
}
.dropdown li, .dropdown li ul li
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 1px 0 0 0;
list-style-type: none;
padding: 0;
}
.dropdown li a:link, .dropdown li a:visited, .dropdown li ul li a:link, .dropdown li ul li a:visited
{
width: 200px;
height: 44px;
display: block;
float: left;
margin: 0;
color: #ffffff;
background-color: #666666;
text-decoration: none;
text-indent: 12px;
line-height: 44px;
}
http://www.webcredible.co.uk/user-friendly-resources/css/internet-explorer.shtml
^This has helped me on many occasions to find work-arounds for IE.

Resources