CSS Not Working with Wordpress Custom Menus - css

I am trying to install a custom menu in my Wordpress theme. I have successfully enabled the feature and embedded the menu in my layout, the only issue is that the CSS is not working for the menu.
I had a custom CSS called NAV and I also tried just copying and pasting the CSS from the Twenty Eleven them into my CSS (which is called access). But no matter what I do, the navigation style doesn't change. I'm starting to think it might be my embed code. Here it is:
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'access', 'menu_class' => 'access' ) ); ?>
Here is the HTML that is generated:
<div class="access">
<ul id="menu-home" class="access">
<li id="menu-item-10" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-10">About Us
<ul class="sub-menu">
<li id="menu-item-11" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-11">History
</li>
</ul>
</li>
</ul>
</div>
And here is the relevant CSS:
#access {
background: #222; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#252525, #0a0a0a);
background: -o-linear-gradient(#252525, #0a0a0a);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a)); /* older webkit syntax */
background: -webkit-linear-gradient(#252525, #0a0a0a);
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
width: 100%;
}
#access ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 -0.8125em;
padding-left: 0;
}
#access li {
float: left;
position: relative;
}
#access a {
color: #eee;
display: block;
line-height: 3.333em;
padding: 0 1.2125em;
text-decoration: none;
}
#access ul ul {
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
margin: 0;
position: absolute;
top: 3.333em;
left: 0;
width: 188px;
z-index: 99999;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul a {
background: #f9f9f9;
border-bottom: 1px dotted #ddd;
color: #444;
font-size: 13px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 10px 10px;
width: 168px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
background: #efefef;
}
#access li:hover > a,
#access a:focus {
background: #f9f9f9; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
background: -o-linear-gradient(#f9f9f9, #e5e5e5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
color: #373737;
}
#access ul li:hover > ul {
display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
font-weight: bold;
}
#img {border-bottom:2px solid #9bc5c4;margin:0;padding:0;max-height:125px;overflow:hidden;} #block-cck_blocks-field_hdr_img {height:128px;overflow:hidden;}
#nav {height:45px;background:url(img/main-nav-bkgd.jpg) repeat-x #26243c;width:1008px;height:45px;z-index:90;position:relative;}
#nav ul.nice-menu {width:993px;margin:0 0 0 15px;padding:0;display:inline;}
#nav ul.nice-menu li {display:block;float:left;background:none;border:none;position:relative;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;height:45px;font-size:13px;font-weight:bold;}
#nav ul.nice-menu li a {display:block;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;padding:13px 23px 14px 23px;font-size:13px;font-weight:bold;text-decoration:none;}
#nav ul.nice-menu li a:hover, #nav ul.nice-menu-down li.menuparent:hover a, #nav ul.nice-menu-down li.over a, #nav ul li.active-trail a {background:url(img/nav-over.jpg) repeat-x;}
#nav ul.nice-menu li ul {position:absolute;top:45px;left:0;}
#nav ul.nice-menu li ul li {width:200px;margin:0;padding:0;height:auto!important;}
#nav ul.nice-menu li ul li a, #nav ul.nice-menu-down li.menuparent ul li a {font-size:11px;color:#231f20;font-family:Georgia, "Times New Roman", Times, serif;display:block;clear:both;padding:5px 20px;margin:0;width:160px;background:#dfccb0!important;border-bottom:1px solid #FFF;font-weight:normal;}
#nav ul.nice-menu li ul li a:hover, #nav ul.nice-menu-down li.menuparent ul li a:hover {background:#d0b389!important;}
#nav ul.nice-menu li ul li ul {display:none;}
Any input on what I could be doing wrong???

Your navigation wrapper has a class of "active" but in your css you are targeting an ID.
Option 1
Change #access to .access
Option 2 (which might be easier)
Change <div class="access"> to <div id="access">
Working example

Related

Responsive Navbar Won't Change Position When Resizing [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Despite the fact my original account mysteriously disappeared, here's my question for the geniuses over on this site:
For a long time now, I've been 'attempting' to build a response Wordpress theme from scratch so that I can keep all of my ideas on one website. The issue happens to be with the navigation menu. I have a bit of CSS doing the justice on mobile platforms under 600px in width. However, on screens larger than 600px, I have the navbar set so that it's fixed on the webpage and maintains its position when scrolling up and down. When a screen smaller than 600px visits the site, I have it set so that the navbar should change from a fixed to relative position. Despite what I'd changed in my stylesheet, I can't seem to make the navbar switch from a fixed to relative state.
Image of the issue:
http://i.gyazo.com/9e8ac2c12d279bba4e5ff98418c9b0ed.png
When normally on the page over 600px:
http://i.gyazo.com/b54486fb441717e79ed9bd3b44ba2710.png
Here's the code. As you can see, when set to resize under 600px, the position should stay relative, but it doesn't:
.main-navigation {
position: fixed;
float: left;
width: 100%;
display: block;
clear: both;
font-family: 'Open Sans', sans-serif;
background: url('nav-bg.png') repeat center;
color: #fff;
-webkit-box-shadow: 0 3px 6px 0px black;
-moz-box-shadow: 0 3px 6px 0px black;
box-shadow: 0 3px 6px 0px black;
z-index: 999999;
}
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
}
.main-navigation li {
float: left;
}
.main-navigation a {
display: block;
padding: 2.5em 3.5em;
font-size: 14px;
font-size: 1.4rem;
text-decoration: none;
line-height: 1.4em;
color: white;
color: hsl(0, 0%, 100%);
}
.main-navigation ul ul {
position: absolute;
left: 0;
z-index: 99999;
display: none;
float: left;
padding: 0;
background-image: url('nav-bg2.png');
}
.main-navigation ul ul ul {
left: 100%;
top: 0;
}
.main-navigation ul ul a {
width: 200px;
}
.main-navigation ul ul li {}
.main-navigation li:hover > a {
color: #fff;
color: hsl(0, 0%, 100%);
background: #313131;
opacity: 0.4;
}
.main-navigation ul ul :hover > a {}
.main-navigation ul ul a:hover {
background: #313131;
background: hsl(0, 0%, 19%);
}
.main-navigation ul li:hover > ul {
display: block;
}
.main-navigation ul ul li:hover > ul {
display: block;
}
.main-navigation .current_page_item > a,
.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a:hover,
.main-navigation .current-menu-item > a:hover {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
color: #fff;
}
.main-navigation .current_page_ancestor {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
.main-navigation ul ul .current_page_parent,
.main-navigation .current_page_parent .current_page_item > a {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
/* Menu Resize */
.menu-toggle {
display: none;
}
#media screen and (max-width: 600px) {
.menu-toggle {
display: block;
height: 3.75em;
padding: 0 1em;
font-weight: normal;
font-size: 14px;
font-size: 1.4rem;
text-decoration: none;
line-height: 3.75em;
color: white;
background-image: url('nav-bg2.png');
position: relative;
}
.main-navigation.toggled .nav-menu {
display: block;
border-top: 1px solid;
border-top-color: #fff;
border-top-color: hsla(0, 0%, 100%, .5);
}
.main-navigation ul {
display: none;
text-align: center;
padding-left: 0;
background-image: url('nav-bg2.png');
}
.main-navigation li {
float: none;
}
.main-navigation li a {
padding: 1.3em 2em;
}
.main-navigation li li a {
padding-left: 4em;
}
.main-navigation li li li a {
padding-left: 6em;
}
.main-navigation li:hover > a {
background: #313131;
background: hsl(0, 0%, 19%);
}
.main-navigation ul ul,
.main-navigation ul ul ul {
position: relative;
top: inherit;
left: 0;
display: block;
float: none;
background-image: url('nav-bg2.png');
}
.main-navigation ul ul a { width: 100%; }
.main-navigation ul a:hover,
.main-navigation ul ul a:hover {
background: #4d4d4d;
background: hsl(0, 0%, 30%);
}
.main-navigation .current_page_ancestor { background: inherit; }
.main-navigation ul ul .current_page_parent {
color: inherit;
background: inherit;
}
.main-navigation .current_page_item > a,
.main-navigation .current_page_item > a:hover,
.main-navigation .current_page_item li:hover,
.main-navigation .current_page_parent .current_page_item > a {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
}
You never set the position back to relative for .main-navigation - you do so for .menu-toggle (which I assume is your dropdown button?)
Try adding this:
#media screen and (max-width: 600px){
.main-navigation {
position: relative;
float: none;
}
}

10 pixels of transparent space beside my drop down links

I am currently working on my nav bar. One issue I am having is that when I added 10px of padding to my main navigation .navi ul, 10px of clear space got added to all the drop down items under each menu item and I just can't figure out why. You can see this in action here: http://cbchaverhill.onedirectionconnection.com/
Here is my CSS:
.navi {
background: #222; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#252525, #0a0a0a);
background: -o-linear-gradient(#252525, #0a0a0a);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a)); /* older webkit syntax */
background: -webkit-linear-gradient(#252525, #0a0a0a);
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
width: 100%;
}
.navi ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 -0.8125em;
padding-left: 10px;
}
.navi li {
float: left;
position: relative;
}
.navi a {
color: #eee;
display: block;
line-height: 3.333em;
padding: 0 1.2125em;
text-decoration: none;
font-weight: bold;
}
.navi ul ul {
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
margin: 0;
position: absolute;
top: 3.333em;
left: 0;
width: 188px;
z-index: 99999;
}
.navi ul ul ul {
left: 100%;
top: 0;
}
.navi ul ul a {
background: #f9f9f9;
border-bottom: 1px dotted #ddd; color: #444;
font-size: 13px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 10px 10px;
width: 188px;
}
.navi li:hover > a,
.navi ul ul :hover > a,
.navi a:focus {
background: #efefef;
}
.navi li:hover > a,
.navi a:focus {
background: #f9f9f9; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
background: -o-linear-gradient(#f9f9f9, #e5e5e5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
color: #373737;
}
.navi ul li:hover > ul {
display: block;
}
.navi
.current-menu-item > a,
.navi .current-menu-ancestor > a,
.navi .current_page_item > a,
.navi .current_page_ancestor > a {
font-weight: bold;
}
Any help would be greatly appreciated!
The css you apply to the .navi ul also applies to the nested ul's.
.navi ul {
padding-left: 10px;
}
One way to resolve this:
.navi ul ul {
padding-left: 0px;
}
Or:
.navi ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 0;
}

CSS Drop down menu not working for ie8 and flashing shut on iPhone 5 browser

Humans needed... My CSS drop down menu will not show up in ie8 and flashes then shuts on iPhone 5 browsers (responsive design)..using code from a themeforest template. without further adieu here is the code.
HTML
<div id="navigation">
<ul>
<li>Home</li>
<li>About
<ul>
<li>Leadership</li>
<li>Giving</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</li>
</ul>
</div>
CSS
/* Main Navigation
==========================*/
#navigation {
float: right;
}
#navigation ul, #navigation li {
list-style:none;
padding:0;
margin:0;
display:inline;
}
#navigation ul li{
float:left;
position:relative;
}
#navigation ul li a {
font-family: Arial, sans-serif;
display: inline-block;
color: #888;
padding: 40px 6px 10px 6px;
margin: 0 5px;
text-decoration: none;
font-size: 14px;
border-bottom: 3px solid transparent;
}
#navigation ul li a:hover{
border-bottom: 3px solid #555;
}
#navigation ul ul {
opacity: 0;
margin: -3px 0 0 5px;
filter: alpha(opacity=0);
position: absolute;
top:-99999px;
left: 0;
background: #fff;
border: 1px solid #dddddd;
border-top: 3px solid #555;
z-index: 999;
}
#navigation ul ul li a:hover {
border-bottom: 1px solid #ddd;
}
#navigation ul ul li a {
padding: 8px 0;
display: block;
width: 130px;
margin: 0 16px;
font-family: Arial, sans-serif;
font-weight: normal;
font-size: 12px;
border-bottom: 1px solid #dddddd;
border-top: 1px solid transparent;
}
#navigation ul ul ul {
position:absolute;
top:-99999px;
left:100%;
opacity: 0;
margin: -3px 0 0 0;
z-index: 999;
}
#navigation ul ul ul li a {
border-bottom: 1px solid #dddddd !important;
border-top: 1px solid transparent;
}
#navigation ul ul li:last-child a, #navigation ul ul li:last-child a:hover {
border-bottom: 1px solid transparent
}
#navigation ul ul ul li:last-child a {
border-bottom: 1px solid transparent !important
}
#navigation ul li:hover>ul{
opacity: 1;
position:absolute;
top:99%;
left:0;
}
#navigation ul ul li:hover>ul{
position:absolute;
top:0; left:100%;
opacity: 1;
z-index:497;
background: #fff border: 0;
}
#navigation ul li:hover > a {
color: #444;
}
#navigation ul ul li:hover > a {
border-top: 1px solid transparent;
color: #444;
}
#current {
font-weight: bold !important;
color: #444 !important;
border-bottom: 3px solid #555 !important;
}
Your problem appears to be with the line:
filter: alpha(opacity=0);
To get this to work in IE8, you need to include the line:
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; /*IE8*/
Alternatively, removing the line entirely doesn't seem to break anything. You might need to play around with different browsers and see what happens.
There's a more in-depth discussion on opacity in IE8 here: Opacity in web pages?
I'm afraid I can't help you on the iPhone side of things.
You also appear to have a bug in your code:
#navigation ul ul li:hover>ul{
position:absolute;
top:0; left:100%;
opacity: 1;
z-index:497;
background: #fff border: 0;
}
You're missing a semi colon after #fff on the last line. Use the W3C CSS Validator to help you trap bugs like this.

Center Navbar and prevent current-item different #font-face from overwriting #navigation container border

This is a two part question... I'm currently trying to get a navbar to work correctly inside my client's crazy parameters.
in style.css:
.fl{float: left;}
/* 2.2 Navigation */
#navigation {
position: relative;
clear: both; margin-bottom: 3em; display: none;
font:14px/14px sans-serif;
border: 1px solid #d9d9d9;
background: #ffffff;
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#f5f5f5));
background: -webkit-linear-gradient(#ffffff, #f5f5f5);
background: -moz-linear-gradient(center top, #ffffff 0%, #f5f5f5 100%);
background: -moz-gradient(center top, #ffffff 0%, #f5f5f5 100%);
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
-webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
-moz-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.03);
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#navigation ul.rss { float: none; position: absolute; top: 10px; right: 9px; }
#navigation ul.rss li { display: block; margin: 0 0 10px 0; padding: 0; font-size: 1em; }
#navigation ul.rss li a { color: #555555; text-decoration: none; padding: 0; display: inline-block; position: relative; }
#navigation ul.rss li a:hover { color: #222; }
ul.nav li a { padding: .5em 1em; display: block; color: #666; }
ul.nav li a:hover { color: #222; }
ul.nav li.current_page_item a,
ul.nav li.current_page_parent a,
ul.nav li.current-menu-ancestor a,
ul.nav li.current-cat a,
ul.nav li.current-menu-item a { background: #ffffff; color: #3088ff; }
ul.nav li ul li a { background: none!important; color: #666!important; }
ul.nav ul li.current_page_item a,
ul.nav ul li.current_page_parent a,
ul.nav ul li.current-menu-ancestor a,
ul.nav ul li.current-cat a,
ul.nav ul li.current-menu-item a { color: #3088ff!important; }
#header .nav-toggle { text-align: center; display: block; margin: 2.5em 0 0; padding: 0.4em 1em; font-size: 1em; background: #999; border-radius: 3px; }
#header .nav-toggle a { color: #fff; }
#header .nav-toggle a:hover { color: #ccc; text-decoration: none; }
#top select { margin: 1.618em 0 0; width:100%; }
#top #top-nav { display: none; }
in layout.css
#navigation { display: block !important; }
#navigation ul li:first-child, #navigation ul li:first-child a { border-radius: 5px 0 0 5px; -moz-border-radius: 5px 0 0 5px; -webkit-border-radius: 5px 0 0 5px; }
#navigation ul ul li:first-child, #navigation ul ul li:first-child a { border-radius: 0; -moz-border-radius: 0; -webkit-border-radius: 0; }
#navigation ul.nav > li { border-right: 1px solid #e6e6e6; }
#navigation ul.nav > li a:hover { background: #f6f6f6; }
#navigation ul.nav > li:hover { background: #f6f6f6; }
#navigation ul.nav ul { background: #f6f6f6; border: 1px solid #e6e6e6; left: -1px; }
#navigation ul.nav ul ul { top: -1px; left: 100%; }
#top .nav li.parent > a { position: relative; padding-right: 2em; }
#top .nav li.parent > a:after { content: ""; display: block; border: .3em solid #ccc; border-color: #ccc transparent transparent transparent; position: absolute; top: 48%; right: .8751em; }
#navigation .nav li ul li.parent a { padding-right: 0; }
#navigation .nav li ul li.parent a:after { border-color: transparent transparent transparent #ccc; right: 0; top: 46%; }
#navigation .nav li.parent > a { position: relative; padding-right: 2em; }
#navigation .nav li.parent > a:after { content: ""; display: block; border: 0.3em solid #ccc; border-color: #ccc transparent transparent transparent; position: absolute; top: 48%; right: .8751em; }
#navigation .nav li ul li.parent a { padding-right: 0; }
#navigation .nav li ul li.parent a:after { border-color: transparent transparent transparent #ccc; right: 0.8751em; top: 46%; }
#header h3.nav-toggle { display: none; }
In custom.css:
#navigation { width: 70%; margin: -70px auto 70px auto; }
#navigation ul.nav li.current_page_item a, #navigation ul.nav li.current_page_parent a, #navigation ul.nav li.current-menu-ancestor a, #navigation ul.nav li.current-cat a, #navigation ul.nav li.current-menu-item a { font-family: "LaPorteniadelaBocaRegular",serif; text-transform: capitalize; font-size: 16px; margin: -3px 0; }
#navigation ul.nav li.current_page_item a, #navigation ul.nav li.current_page_parent a, #navigation ul.nav li.current-menu-ancestor a, #navigation ul.nav li.current-cat a, #navigation ul.nav li.current-menu-item a { font-family: "LaPorteniadelaBocaRegular",serif; text-transform: capitalize; font-size: 16px; margin: -3px 0; }
part of the page itself (added by WooTheme's Canvas theme):
ul.nav li a, #navigation ul.rss a { font:bold 14px/1em 'Josefin Sans', arial, sans-serif;color:#FFFFFF; }
#navigation ul.nav > li a:hover, #navigation ul.nav > li:hover, #navigation ul.nav li ul {background-color:#70c8c6!important}
#navigation ul.nav li ul { border: 1px solid #FFFFFF; }
#navigation ul.nav > li { border-right: 0px solid #dbdbdb; }#navigation ul.nav > li > ul { left: 0; }
#navigation ul.nav li.current_page_item a, #navigation ul.nav li.current_page_parent a, #navigation ul.nav li.current-menu-ancestor a, #navigation ul.nav li.current-cat a, #navigation ul.nav li.current-menu-item a { background-color:transparent; }
#navigation ul.nav li.current_page_item a, #navigation ul.nav li.current_page_parent a, #navigation ul.nav li.current-menu-ancestor a, #navigation ul.nav li.current-cat a, #navigation ul.nav li.current-menu-item a { color:#ffffff; }
#navigation ul li:first-child, #navigation ul li:first-child a { border-radius:0px 0 0 0px; -moz-border-radius:0px 0 0 0px; -webkit-border-radius:0px 0 0 0px; }
#navigation {background:transparent;border-top:1px solid #FFFFFF;border-bottom:1px solid #FFFFFF;border-left:0px solid #dbdbdb;border-right:0px solid #dbdbdb;border-radius:0px; -moz-border-radius:0px; -webkit-border-radius:0px;}
And, the HTML itself:
<div id="navigation" class="col-full">
<ul id="main-nav" class="nav fl"><li id="menu-item-17" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-17">Weddings & Events</li>
<li id="menu-item-41" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-24 current_page_item menu-item-41">Services</li>
<li id="menu-item-40" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-40">About</li>
<li id="menu-item-39" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-39">Praise</li>
<li id="menu-item-38" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-38">Press</li>
<li id="menu-item-37" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-37">Contact</li>
<li id="menu-item-36" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-36">Blog</li>
</ul>
</div>
Ok, I think I have all the code in there.. Basically, what I want is to have a top and bottom border on #navigation, then have the nav items themselves centered automatically, and finally allow the active-item (which since it's a different font, needs a small margin adjustment so that it's in "line" with the other nav items), when :hovered, to not overwrite the top/bottom border.
No hover effect, looks "fine" - http://content.screencast.com/users/WolfSnap/folders/Snagit/media/051b5d52-a234-4714-90e9-cd772db5b6dc/2012-07-07_15-09-37.png
With hover effect, border goes away! - http://content.screencast.com/users/WolfSnap/folders/Snagit/media/7b921116-f7fa-4e4f-b5c1-10fe865c409b/2012-07-07_15-10-57.png

first-child is not working properly in my css code

I have a problem using first-child
I have the following html code to make a menu with first and second levels
<ul id="navMenu" >
<li class="parent">Home
</li>
<li class="parent">Products
<ul ><li>Software
<ul>
<li>Product 1</li>
<li>Product 2</li>
<li>Product 3</li>
</ul>
</li>
<li>Hardware
<ul>
<li>Product 1</li>
<li>Product 2</li>
</ul>
</li>
</ul>
</li>
</ul>
and the following css
#menuContainer{
float: right;
}
ul#navMenu{
margin: 25px 0 0;
list-style: none outside none;
}
ul#navMenu li{
float: left;
margin: 0 0 0 0px;
position: relative;
z-index: 999;
}
ul#navMenu li a{
display: block;
padding: 5px 0px;
font-size: 13px;
line-height: 12px;
background: transparent;
color: #444;
-webkit-transition: background-color 0.1s linear, color 0.1s linear;
-moz-transition: background-color 0.1s linear, color 0.1s linear;
}
ul#navMenu li.parent a{
padding-right: 23px;
background-color: transparent;
background-repeat: no-repeat;
background-position: right top;
font-family: "Lucida Grande", Tahoma, Arial, sans-serif;
text-transform: uppercase;
}
ul#navMenu li a:hover, ul#navMenu li.current a{
color: #CB0167 ;
text-decoration: none;
font-family: "Lucida Grande", Tahoma, Arial, sans-serif;
}
ul#navMenu li.parent a:hover, ul#navMenu li.current.parent a{
background-position: right bottom;
}
/* - -- --- ---- Sub-Menu ---- --- -- - */
ul#navMenu li.parent ul{
display: none;
position: absolute;
top: 25px;
left: 0;
width: 160px;
margin: 0;
padding: 0px 0 0;
list-style: none outside none;
overflow: visible;
z-index: 99;
border-top: 1px solid #eee;
}
.noJs ul#navMenu li.parent:hover ul{
display: block;
}
ul#navMenu li.parent ul li{
float: none;
margin: 0;
padding: 0;
}
ul#navMenu li.parent ul li a{
display: block;
padding: 7px 10px;
color: #444;
background: #fff;
font-size: 11px;
border-right: 1px solid #eee;
border-left: 1px solid #eee;
text-transform: none;
background-image: url('../img/dots_menu.png');
background-repeat: no-repeat;
}
ul#navMenu li.parent ul li:first-child a{
background-image: none;
}
ul#navMenu li.parent ul li:first-child a:hover{
background-image: none;
}
ul#navMenu li.parent ul li:last-child a{
box-shadow: 0 1px 0 rgba(0,0,0,0.05);
border-bottom: 1px solid #eee;
}
ul#navMenu li.parent ul li a:hover{
color: #CB0167 !important;
background: #fefefe;
background-image: url('../img/dots_menu.png');
background-repeat: no-repeat;
}
/* - -- --- ---- Second Level Sub-Menu ---- --- -- - */
ul#navMenu li.parent ul li ul{
display: none;
position: absolute;
top: -1px;
left: 159px;
width: 160px;
margin: 0;
padding: 0 0 0 0px;
border-top: 1px solid #eee;
}
ul#navMenu li.parent ul li ul.leftMenu{
left: -168px;
padding: 0 10px 0 0;
}
.noJs ul#navMenu li.parent:hover ul li ul{
display: none;
}
.noJs ul#navMenu li.parent ul li:hover ul{
display: block;
}
ul#navMenu li.parent ul li ul li:first-child a{
background-image: none;
}
ul#navMenu li.parent ul li ul li:first-child a:hover{
background-image: none;
}
The menu product is exactly what I need , and the hardware menu , but the software menu is not working , any idea how to fix it ??
Thanks a lot :)
using the > you can prevent the style affect the grandchild's , so try to change this
ul#navMenu li.parent ul li:first-child a{
to this
ul#navMenu li.parent ul li:first-child > a{
also
ul#navMenu li.parent ul li:first-child a:hover{
with this
ul#navMenu li.parent ul li:first-child > a:hover{
your code is too messed up... you can replicate the same without <ul> and <li>.. here's a small snippet of your menu of home/products .. home you find your solution here..
http://jsfiddle.net/NMrMN/
You can apply the necessary css yo your specific needs.. but,using div's to achieve this would give you more freedom on how to place the elements on the page.. so,this is my solution to what i think is your problem..

Resources