superfish menu styling issue - css

Im trying to style my superfish menu in my Wordpress theme. Im trying to elimate the gap between the dropdown when on hover.
As you can see from the picture there is a small gap.
I have tried to edit the below code which i believe is applicable to the section in question. However when applying a negative margin its making the options overlap as shown.
Im currently editting the below code:-
.sf-menu li li {
background: #193030;
}
however placing a margin-top: -10px; produces this:-
Your help and advice is appreciated.
thanks
EDIT
Please see full CSS of superfish :)
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu {
line-height: 1.0;
}
.sf-menu ul {
position: absolute;
top: -999em;
width: 10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width: 100%;
}
.sf-menu li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float: left;
position: relative;
}
.sf-menu a {
display: block;
position: relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left: 0;
top: 2.5em; /* match top ul list item height */
z-index: 99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left: 10em; /* match ul width */
top: -10;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left: 10em; /* match ul width */
top: 0;
}
/*** DEMO SKIN ***/
.sf-menu {
float: left;
margin-bottom: 1em;
}
.sf-menu a {
border-right: 1px solid #193030;
padding: .75em 1em;
text-decoration:none;
font: 11.5px Open Sans;
text-transform: uppercase;
color: #fff;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
color: #fff;
}
.sf-menu li {
background: transparent;
}
.sf-menu li a {color: #fff;}
.sf-menu li li {
background: #193030;
margin-top: -0px;
}
.sf-menu li li a:hover {background-color: #0a1c1c;}
.sf-menu li li li {
background: #9AAEDB;
}
.sf-menu li:hover, .sf-menu li.sfHover,
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
background: #193030;
outline: 0;
}
/*** arrows **/
.sf-menu a.sf-with-ul {
padding-right: 2.25em;
min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
}
.sf-sub-indicator {
position: absolute;
display: block;
right: .75em;
top: 1.5em; /* IE6 only */
width: 10px;
height: 10px;
text-indent: -999em;
overflow: hidden;
background: url('images/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */
}
a > .sf-sub-indicator { /* give all except IE6 the correct values */
top: 1.0em;
background-position: 0 -100px; /* use translucent arrow for modern browsers*/
}
/* apply hovers to modern browsers */
a:focus > .sf-sub-indicator,
a:hover > .sf-sub-indicator,
a:active > .sf-sub-indicator,
li:hover > a > .sf-sub-indicator,
li.sfHover > a > .sf-sub-indicator {
background-position: -10px -100px; /* arrow hovers for modern browsers*/
}
/* point right for anchors in subs */
.sf-menu ul .sf-sub-indicator { background-position: -10px 0; }
.sf-menu ul a > .sf-sub-indicator { background-position: 0 0; }
/* apply hovers to modern browsers */
.sf-menu ul a:focus > .sf-sub-indicator,
.sf-menu ul a:hover > .sf-sub-indicator,
.sf-menu ul a:active > .sf-sub-indicator,
.sf-menu ul li:hover > a > .sf-sub-indicator,
.sf-menu ul li.sfHover > a > .sf-sub-indicator {
background-position: -10px 0; /* arrow hovers for modern browsers*/
}
/*** shadows for all but IE6 ***/
.sf-shadow ul {
background: url('../images/shadow.png') no-repeat bottom right;
padding: 0 8px 9px 0;
-moz-border-radius-bottomleft: 17px;
-moz-border-radius-topright: 17px;
-webkit-border-top-right-radius: 17px;
-webkit-border-bottom-left-radius: 17px;
}
.sf-shadow ul.sf-shadow-off {
background: transparent;
}

this has now been fixed thanks to the lovely Florian..
I needed to amend
.sf-menu li.sfHover ul {
left: 0;
top: 2.1em; /* match top ul list item height */
z-index: 99;
}
This stated how far the UL was from the top.
I hope this knowledge helps others too.

Related

css hover drop down parent color

Is there a way to keep the a:hover {color:#ffffff } white color also when i'm hovering the sub menu?
http://jsfiddle.net/Lg7q0nen/
Replace this line:
.sf-menu li a:hover { color:#ffffff; }
By this one:
.sf-menu li:hover a { color:#ffffff; }
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu li {
position: relative;
}
.sf-menu ul {
position: absolute;
display: none;
top: 100%;
left: 0;
z-index: 99;
}
.sf-menu > li {
float: left;
}
.sf-menu li:hover > ul,
.sf-menu li.sfHover > ul {
display: block;
}
.sf-menu li { text-transform:uppercase; color:#555a60; }
.sf-menu a {
display: block;
position: relative;
}
.sf-menu ul ul {
top: 0;
left: 100%;
}
.sf-menu i {
position:absolute;
margin:1px 4px;
font-size:18px;
color:#dfd301;
}
.sf-menu i:hover { color:#ffffff; }
/*** DEMO SKIN ***/
.sf-menu {
float: left;
margin-bottom: 1em;
}
.sf-menu ul {
box-shadow: 2px 2px 6px rgba(0,0,0,.2);
min-width: 12em; /* allow long menu items to determine submenu width */
*width: 12em; /* no auto sub width for IE7, see white-space comment below */
}
.sf-menu a {
min-width: 113px;
text-align: center;
padding:20px 16px;
text-decoration: none;
zoom: 1; / IE7 /
}
.sf-menu a {
color: #555a60;
}
.sf-menu li {
/*background: #BDD2FF;*/
white-space: nowrap; /* no need for Supersubs plugin */
*white-space: normal; /* ...unless you support IE7 (let it wrap) */
-webkit-transition: background .2s;
transition: background .2s;
}
.sf-menu li ul li a { padding:10px; text-align:left; color:#ffffff; }
.sf-menu li ul li a:hover { color:#ffffff; }
.sf-menu li ul li { background:#777777; color:#ffffff; }
.sf-menu ul li {
min-width:180px;
text-transform:uppercase; color:#555a60;
}
.sf-menu ul ul li {
background: #9AAEDB;
}
.sf-menu li:hover,
.sf-menu li.sfHover {
background: #b01523;
color:#ffffff;
/* only transition out, not in */
-webkit-transition: none;
transition: none;
}
.sf-menu li:hover a { color:#ffffff; }
/*** arrows (for all except IE7) **/
.sf-arrows .sf-with-ul {
padding-right: 2.5em;
*padding-right: 1em; /* no CSS arrows for IE7 (lack pseudo-elements) */
}
/* styling for both css and generated arrows */
.sf-arrows .sf-with-ul:after {
content: '';
position: absolute;
top: 50%;
right: 1em;
margin-top: -3px;
height: 0;
width: 0;
/* order of following 3 rules important for fallbacks to work */
border: 5px solid transparent;
border-top-color: #dFeEFF; /* edit this to suit design (no rgba in IE8) */
border-top-color: rgba(255,255,255,.5);
}
.sf-arrows > li > .sf-with-ul:focus:after,
.sf-arrows > li:hover > .sf-with-ul:after,
.sf-arrows > .sfHover > .sf-with-ul:after {
border-top-color: white; /* IE8 fallback colour */
}
/* styling for right-facing arrows */
.sf-arrows ul .sf-with-ul:after {
margin-top: -5px;
margin-right: -3px;
border-color: transparent;
border-left-color: #dFeEFF; /* edit this to suit design (no rgba in IE8) */
border-left-color: rgba(255,255,255,.5);
}
.sf-arrows ul li > .sf-with-ul:focus:after,
.sf-arrows ul li:hover > .sf-with-ul:after,
.sf-arrows ul .sfHover > .sf-with-ul:after {
border-left-color: white;
}
<ul class="sf-menu">
<li>home</li>
<li>
blog
<ul>
<li>Option1</li>
<li>Option2</li>
<li>Option3</li>
</ul>
</li>
<li>page
</li>
<li>contact
</li>
</ul>
On line 95 you can do .sf-menu li:hover a
The key is that you are using the :hover on the li and traverse further after it.
Put the :hover on the whole li.
I added this at the end of your css and it seems to work.
.sf-menu > li:hover > a {
color: white;
}
There's probably a better place to put it, but there was a lot of code there...
http://jsfiddle.net/vvf0shvg/

Responsive CSS issues on my shop

I have some responsive issues on my prestashop site on the top menu block.
Can you please help me solve them?
On media width 500px:
- The height of the categories on the top menu are too high, the "Novedades" item cannot be seen.
On media width 600px:
- The menu subcategories are dropped down automatically by themselves.
On media width 1000px:
- The cloud on "Novedades" item is not set correctly must be a little higher.
Here is the code
/*** ESSENTIAL STYLES ***/
.sf-contener {
clear: both;
}
.sf-right {
margin-right: 14px;
float: right;
width: 7px;
}
.sf-menu, .sf-menu * {
margin: 0;
padding: 0px 0px 0px 0px;
list-style: none;
}
.sf-menu {
margin: 10px 0;
padding:0px 0px 0px 0px;
width:980px;/* 980 */
background: #383838;
/* #media (max-width: 450px) {
.sf-menu {
display: none; } */
}
.sf-menu ul {
position: absolute;
top: -999em;
width: 10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width: 100%;
}
.sf-menu li:hover {
visibility: inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float: left;
position: relative;
top: 0;
/*border-right: 1px solid #777;*/
}
.sf-menu a {
display: block;
position: relative;
color:#fff;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left: 0;
/*padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;*/
top: 35px; /* match top ul list item height */
z-index: 99;
width:auto;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top: -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left: 200px; /* match ul width */
top: 0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
left: 200px; /* match ul width */
top: 0;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left: 200px; /* match ul width */
top: 0;
}
/*** DEMO SKIN ***/
.cat-title {
display: none;
}
.sf-menu {
float: left;
margin-bottom: -2em;
width: 100%;
height: 75px;
background: url('http://www.dulcewashitape.com/themes/dulcewashitape/img/cabecera.png') repeat left center;
}
.sf-menu a {
position: relative;
top: 20px;
display:block;
margin-right:2px;
padding: 0 22px 0 20px;
line-height:35px;
border: 10;
text-decoration:none;
text-transform: uppercase;
font-family:Handlee;
font-size: 18px;
font-weight: bold;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
color: #916e6e;
white-space:nowrap;
}
.sf-menu li ul {
border:1px solid #f1b6b1; box-shadow:2px 2px 4px rgba(0,0,0,0.25);
width:500px;
padding: 0;
margin: 23px 0px 0px 0px;
top:0;
background: white;
}
.sf-menu li li {
background: white;
position: relative;
top: 0;
height:35px;
line-height:35px;
padding: 0;
margin: 0px 0px 0px 0px;
}
.sf-menu li li a {
font-size: 16px;
text-transform: capitalize;
top:0;
}
.sf-menu li li li {
background: white;
width:140px;
}
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
font-weight: bold;
color: white;
background: url('http://www.dulcewashitape.com/themes/dulcewashitape/img/boton-b.png') no-repeat center 0px;
}
.sf-menu ul li:hover, .sf-menu ul li.sfHover,
.sf-menu ul li a:focus, .sf-menu ul li a:hover, .sf-menu ul li a:active {
background: #eecfd0; //#4e4e4e;
outline: 0;
}
/*** arrows **/
.sf-menu a.sf-with-ul {
padding-right: 2.25em;
min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
padding-top: 20px;
margin-top: -20px;
}
.sf-sub-indicator {
position: absolute;
display: block;
right: 10px;
top: 1.05em; /* IE6 only */
width: 10px;
height: 35px;
text-indent: -999em;
overflow: hidden;
background: url('../img/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */
}
a > .sf-sub-indicator { /* give all except IE6 the correct values */
top: 11px;
background-position: 0 -100px; /* use translucent arrow for modern browsers*/
}
/* apply hovers to modern browsers */
a:focus > .sf-sub-indicator,
a:hover > .sf-sub-indicator,
a:active > .sf-sub-indicator,
li:hover > a > .sf-sub-indicator,
li.sfHover > a > .sf-sub-indicator {
background-position: -10px -100px; /* arrow hovers for modern browsers*/
}
/* point right for anchors in subs */
.sf-menu ul .sf-sub-indicator { background-position: -10px 0; }
.sf-menu ul a > .sf-sub-indicator { background-position: 0 0; }
/* apply hovers to modern browsers */
.sf-menu ul a:focus > .sf-sub-indicator,
.sf-menu ul a:hover > .sf-sub-indicator,
.sf-menu ul a:active > .sf-sub-indicator,
.sf-menu ul li:hover > a > .sf-sub-indicator,
.sf-menu ul li.sfHover > a > .sf-sub-indicator {
background-position: -10px 0; /* arrow hovers for modern browsers*/
}
/*** shadows for all but IE6 ***/
.sf-shadow ul {
background: url('../img/shadow.png') no-repeat bottom right;
padding: 0 8px 9px 0;
-moz-border-bottom-left-radius: 17px;
-moz-border-top-right-radius: 17px;
-webkit-border-top-right-radius: 17px;
-webkit-border-bottom-left-radius: 17px;
}
.sf-shadow ul.sf-shadow-off {
background: transparent;
}
li.sf-search {
background: inherit;
float: right;
line-height: 25px;
background:transparent;
}
li.sf-search input {
-moz-border-radius: 0 5px 5px 0;
padding: 5px 0;
position: relative;
top: 1px;
padding-left: 30px;
margin: 18px 6px 0 0;
background: #fff url('../../../../img/search-zoom3.png') no-repeat left center;
border:1px solid #777;
}
/* hack IE7 */
.sf-menu a, .sf-menu a:visited {height:34px !IE;}
.sf-menu li li {
width:200px;
background:#726f72 !IE;
}
#block_top_menu .category-thumbnail {
display:none;
clear: both;
width: 100%;
float: none; }
#block_top_menu .category-thumbnail div {
float: left;
width: 33.33333%; }
#block_top_menu .category-thumbnail div img {
max-width: 100%; }
#block_top_menu li.category-thumbnail {
padding-right: 0; }
/* Mobile Item */
.sf-menu-phone-item { display:none; }
#sf-menu-phone-trigger { display:none; position:absolute; top:7px; right:0; background:url('http://www.dulcewashitape.com/themes/dulcewashitape/img/icon-mobile-nav.png') top right no-repeat #29addd; width:50px; height:50px; text-indent:-9999px; border-radius:3px;
-webkit-transition: all 0.5s ease 0s;
-moz-transition: all 0.5s ease 0s;
-o-transition: all 0.5s ease 0s;
transition: all 0.5s ease 0s; }
#sf-menu-phone-trigger:hover { background-color:#333; }
#sf-menu-phone-trigger.active { background-position:bottom right; }
#media only screen and (max-width: 999px) {
.sf-menu a, .sf-menu a:visited {font-size:13px;}
}
/* Tablet Only Queries */
#media only screen and (min-width: 531px) and (max-width: 786px) {
.sf-menu a, .sf-menu a:visited {font-size:12px;}
}
/* Phone Only Queries */
#media only screen and (max-width: 530px) {
#sf-menu-header {height:auto; }
#sf-menu-top-nav {margin-left:-2%; margin-right:-2%;}
/*.sf-menu {display:none; } */
.sf-menu {width:100%; height:auto; margin:10px 0 0 0; position:static !important}
.sf-menu li {width:100%; background:#f4f4f4; border-top:1px solid #fff !important; border-bottom:1px solid #999 !important; -webkit-border-radius:0; border-radius:0; }
.sf-menu li:hover {background:#de8686;}
.sf-menu li ul {width:100%; position:static !important; background:#ccc;}
.sf-menu li li {width:100% !important; background:#ccc; }
/*.sf-menu li li li {display:none !important;}*/
.sf-menu-phone-item { display:block; }
#sf-menu-phone-trigger { display:block; }
.sf-search {padding:10px;}
#searchbox {margin-left:15px;}
#searchbox input[type="text"] {width:80%;}
#searchbox input[type="text"]:focus, #searchbox input[type="text"]:hover {width:80%;}
#searchbox .button {width:10%;}
#header_logo { padding-right:50px; text-align:left !important;}
}
And the site is : [www.dulcewashitape.com][1]
Thank you very much I really appreciate your help
On media width 1000px: The "Washi Tape" text is reading the CSS for the a.sf-with-ul class whereas the "Novedades" is executing the CSS for a, and they have differing CSS values.
Take the CSS in a.sf-with-ul and apply it to the a to align your clouds:
ul.sf-menu li a {
padding-right: 2.25em;
min-width: 1px;
padding-top: 20px;
margin-top: -20px;
}
On media width 500px: You have a top:20px; that pushes your text down assigned inside .sf-menu a. Removing it is not an option since it causes misalignment at higher screen widths to your menu. Given this constraint, you can create a special rule using the following to only apply your desired top:5px; if the screen width is less than or equal to 500px
#media screen (max-width: 500px) {
.sf-menu a{
top:5px;
}
}
Unfortunately I do now know how to fix the automatically dropping down menu, goodluck!

How to stick a background behind the navbar?

I have a problem here.
I'm using wordpress and I was confused.
How to stick background behind the nav bar?.
I activated LowerMedia Sticky.js menu's plugin, then I want to change my navbar background color. I try to add a background: #000; in #navigation. It's look okay, but when I scroll down, the navigation background is not move. There's only the navigation text that moved. I try to move background: #000; to #navigation .sf-menu a but the background is only appear around the text, even it move with the text when I scroll down. I don't know what to do now. Please help me. Thanks before.
This is my site : vitraprawira.net
This is my final navbar css code:
/* Main Navigation
================================================== */
/*hide responsive nav*/
#top-bar .selector, #navigation .selector { display: none; }
/*core*/
.sf-menu, .sf-menu * { margin: 0; padding: 0; list-style: none; }
.sf-menu { line-height: 1.0 }
.sf-menu ul { position: absolute; top: -999em; width: 180px; }
.sf-menu ul li { width: 100% }
.sf-menu li:hover { visibility: inherit }
.sf-menu li { float: left; position: relative; }
.sf-menu a { display: block; position: relative; }
.sf-menu li:hover ul, .sf-menu li.sfHover ul { left: 0px; top: 30px; z-index: 99; }
ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul { top: -999em }
ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul { left: 180px; top: 1px; }
/*styling*/
#navigation-wrap { position: relative; display: block; }
#navigation { margin-left: 170px; margin-right: auto; position: relative; height: 55px; transparent: none; }
#navigation .sf-menu > li:hover > ul, .sf-menu li.sfHover > ul { top: 50px }
#navigation ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul, ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul { left: 200px; top: 0; }
#navigation .sf-menu a { font-size: 1.000em; height: 55px; line-height: 55px; color: #fff; background: #000 url("images/vintage.png"); }
#navigation .sf-menu > li > a { border-radius: 2px; -moz-border-radius: 2px; -webkit-border-radius: 2px; }
#navigation .sf-menu li { float: left; position: relative; }
#navigation .sf-menu > li { background: url("images/dash.png") right center no-repeat; margin-right: 20px; padding-right: 20px; }
#navigation .sf-menu > li:last-child { margin: 0; padding: 0; }
#navigation .sf-menu > li > a:hover { color: #fff }
#navigation .sf-menu > .current-menu-item > a { color: #7094DB }
#navigation .sf-menu > li.sfHover > a { color: #fff }
/*drop-down styles*/
#navigation .sf-menu ul { position: absolute; nowhitespace: afterproperty; top: -999em; width: 200px; z-index: 9999; left: 0; border: 1px solid #ddd; box-shadow: 0 0 8px rgba(0,0,0,0.08); }
#navigation .sf-menu ul > li:last-child { -webkit-border-bottom-right-radius: 2px; -webkit-border-bottom-left-radius: 2px; -moz-border-radius-bottomright: 2px; -moz-border-radius-bottomleft: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; }
#navigation .sf-menu ul li { background: #000; border-bottom: 1px solid rgba(0,0,0,0.05); }
#navigation .sf-menu ul li:first-child { border-top: 0 }
#navigation .sf-menu ul li:last-child { border-bottom: 0 }
#navigation .sf-menu ul a { display: block; padding: 10px; color: #fff; height: auto; margin: 0px; border: 0px; line-height: 1.8em; font-size: 0.923em; text-shadow: none; }
#navigation .sf-menu ul li > a:hover { color: #7094DB; background: #2D3B58; }
If you're wanting the color/image to appear behind the entire menu block, then you're localizing the background too close to the anchor element.
Just do this: #navigation {background: #ccc;} or whatever color you want.

CSS menu and sub menu issues + browser px issues for webkit [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Here where my css menu is: My css menu
Notice if you hover over "about us" like below you see the "our clergy" sub menu already out. I don't want that I want it when you hover over "our clergy" for it to show.
This screenshot above is from firefox, while webkit browsers show a 1-2px difference as seen below and I can't figure out why? It sometimes effects how the menu works too.
Here is my css for the menu (I'm using wordpress so that means there is no html):
Feel free to help me out and if you want to clean up the css you can too!
#navbar {
height: 40px;
padding-left: 10px;
margin-left:-10px;
margin-top: -29px;
margin-bottom:0;
background: #F4DE9F;
width:930px;
/*backgroundborder-top: 2px solid #F4DE9F;
border-bottom: 2px solid #F4DE9F;*/
}
#navbar li {
float: left;
list-style: none;
margin-bottom: 30px;
margin-left:-20px;
}
#navbar li a {
font-family: "MuseoSans_500";
color: #3C290B;
font-weight: 500;
text-transform: uppercase;
}
#navbar li:hover {
background:rgba(255, 241, 194, 100); /*#FFF1C2;*/
color: #645548;
text-decoration: none;
}
#navbar li a:hover {
background:rgba(255, 241, 194, 100); /*#FFF1C2;*/
color: #645548;
text-decoration: none;
}
#navbar .parent > a, #navbar .parent > a:hover {
background: #F4DE9F;
background-position: right;
background-repeat: no-repeat;
}
#navbar ul, #navbar ul li {
display: inline;
list-style: none;
margin: 0;
padding: 0;
}
#navbar ul li a {
display: inline-block;
padding: 11px 16.2px 8px;
text-decoration: none;
}
/*
#navbar ul li a:hover {
}
#navbar ul #first a:hover {
}*/
#navbar ul li {
position: relative;
}
#navbar li ul {
display: none;
left: 11px;
position: absolute;
top: 51px;
}
#navbar li ul a {
background: #F4DE9F;
}
#navbar ul ul ul li {
}
#navbar ul li:hover ul {
display: inline-block;
}
#navbar ul li:hover ul, #navbar ul ul li:hover ul, #navbar ul ul ul li:hover ul {
display: block;
margin: -11px 0 0 -11px;
}
/*#navbar ul li:hover ul li a, #navbar ul ul li:hover ul li a, #navbar ul ul ul li:hover ul li a {
display: block;
}*/
#navbar ul li:hover ul ul, #navbar ul ul li:hover ul ul {
margin-top: -50px;
margin-left:129px;
}
#navbar ul li:hover ul li a {
padding: 10px 14px 8px;
width: 112px;
}
#navbar ul li:hover ul ul li a {
padding: 10px 14px 8px;
width: 112px;
}
/*#navbar ul ul ul li:hover ul li a {
padding: 0 16px 0 24px;
width: 140px;
}*/
#navbar .children li a:hover {
color: #000;
}
When you end up with a stylesheet that feels very bloated with several rules and a lot of specificity, such as #navbar ul ul ul li:hover ul it is usually good to take a step back see if you can simplify the rules a bit.
Since you are using Wordpress it comes with a lot of handy classes that makes the job easier. In this case .menu-item and .sub-menu.
Replacing the menu-css with the following styles solves the problems you mentioned in your question, tried in Chrome 23, Safari 6 and Firefox 16.
Example here: http://jsfiddle.net/5qEwH/
.menu-item {
display: inline-block;
position: relative;
font-family: "MuseoSans_500";
font-weight: 500;
text-transform: uppercase;
background: #F4DE9F;
}
.menu-item:hover {
background: #FFF1C2;
}
.menu-item a {
display: inline-block;
height: 20px;
padding: 10px;
text-decoration: none;
color: #645548;
}
/* Hide submenus by default */
.sub-menu {
display: none;
position: absolute;
width: 150px;
top: 40px;
}
.sub-menu .menu-item {
width: 100%;
}
/* The second level sub-menu should be moved to the right */
.sub-menu .menu-item > .sub-menu {
top: 0;
left: 150px;
}
/* Show submenus on hover */
.menu-item:hover > .sub-menu {
display: block;
}
Its a great CSS practice to normalize your styles first so that all the browsers get the same styles for some basic HTML elements.
I add this at the start of a Stylesheet
* { margin: 0px; padding: 0px; border: 0px; text-decoration: none }
There is also a comprehensive stylesheet file for normalization that covers all the browsers and even html5 as well. try to add this before your style.css file.
Here is the link: http://necolas.github.com/normalize.css/
For the hover issue, try this css change
Replace
#navbar ul li:hover ul {
display: inline-block;
}
#navbar ul li:hover ul, #navbar ul ul li:hover ul, #navbar ul ul ul li:hover ul {
display: block;
margin: -11px 0 0 -11px;
}
With
#navbar ul li:hover > ul {
display: inline-block;
}
#navbar ul li:hover > ul, #navbar ul ul li:hover > ul, #navbar ul ul ul li:hover > ul {
display: block;
margin: -11px 0 0 -11px;
}
Hope it helps :)

CSS Menu link stays highlighted

So I'm trying my hands at a css menu and I have a simple bug that I cannot fix and haven't found any help searching for it. The issue is that when I hover over a drop down menu the parent link stays highlighted and the text reverts back to the original color. Hopefully that explains it. Here's the css code, I'm sure it's a matter of adding something or fixing a line of code. You can check out the issue here, everything works fine until you visit a submenu (like in BAR or Info).
#nav, #nav ul {
text-align: center;
text-size:16px;
float: left;
width: 750px;
height: 20px;
list-style: none;
line-height: 1;
background: white;
padding: 0;
border: solid #000;
border-width: 0px;
border-bottom-width: 1px;
margin: 0;
background-image: url('/images/bg.gif');
}
#nav a {
display: block;
width: 75px;
height: 20px;
color: #0000FF;
text-decoration: none;
}
#nav a:hover {
display: block;
width: 75px;
height: 20px;
color: #FFF;
}
#nav li {
float: left;
padding: 0;
width: 75px;
}
#nav li ul { /*sub menu */
position: absolute;
left: -999em;
height: auto;
width: 75px;
border: solid #000;
border-width: 0px;
border-bottom-width: 1px;
border-top-width: 1px;
background-image: url('/images/submenu_bg.png');
}
#nav li li {
width: 75px;
}
#nav li ul a {
width: 75px;
}
#nav li ul ul {
margin: -1.75em 0 0 14em;
}
#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
left: -999em;
}
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {
left: auto;
}
#nav li:hover, #nav li.sfhover {
height: 20px;
background: #0000FF;
}
You're setting the text color on #nav a:hover, but the background color on #nav li:hover. Because your submenus are contained within the li, it still counts as being hovered over even while the cursor is in the submenu. The submenus aren't contained within the link, so they don't stay highlighted and revert to their normal color. If you want the menu item to stop highlighting, move the background property to #nav a:hover instead.
Before:
#nav a:hover {
display: block;
width: 75px;
height: 20px;
color: #FFF;
}
#nav li:hover, #nav li.sfhover {
height: 20px;
background: #0000FF;
}
After:
#nav a:hover, #nav li.sfhover a {
display: block;
width: 75px;
height: 20px;
color: #FFF;
background: #0000FF;
}
Alternatively, if you want the menu to stay highlighted while hovering on the submenu (which looks better, IMO), move color to the li:hover. I know it's a little verbose, but it works. :-)
Before:
#nav a:hover {
display: block;
width: 75px;
height: 20px;
color: #FFF;
}
#nav li:hover, #nav li.sfhover {
height: 20px;
background: #0000FF;
}
After:
#nav a:hover {
display: block;
width: 75px;
height: 20px;
}
#nav li:hover a, #nav li.sfhover a {
color:white;
}
#nav li:hover li a, #nav li.sfhover li a {
color:blue;
}
#nav li:hover li a:hover, #nav li.sfhover li a:hover {
color:white;
}
#nav li:hover, #nav li.sfhover {
color: #FFF;
height: 20px;
background: #0000FF;
}
You can try setting the color of the link on the hover of the li, like so:
#nav li:hover a {
color: #fff;
}
#nav li:hover li a
{
color: #0000FF;
}

Resources