change color of menu item when on sub-menu page
-
I am building a site in WordPress using Starkers theme. I have used html to code the main and sub navigations and styled in css. What I am needing to do is make each of the main nav links to change color when on their page and for the parent of the sub menu to be a different color when on their pages. I have tried using current-menu-item and current-parent-item etc but none work. Any ideas??? http://page12.com.au/sample.html
My html
`<nav>
<ul>
<li class=”left1″><a href=”#”>home</a></li>
<li class=”center”><a href=”#”>folio</a>
<ul>
<li><a href=”#”>brand</a></li>
<li><a href=”#”>identity</a></li>
<li><a href=”#”>exhibition</a></li>
<li><a href=”#>illustration</a></li>
<li><a href=”#”>philatelic</a></li>
<li><a href=”#”>publishing</a></li>
</ul>
</li>
<li class=”right”><a href=”#”>contact</a></li>
</ul>
</nav>`CSS
`nav ul {
list-style: none;
font-size: 25px;
font-family: ‘HelveticaNeuel’;
color: rgb(146, 148, 151);
}nav ul li {
display: block;
float: left;
margin-top: 40px;
font-family: ‘HelveticaNeuel’;
color: rgb(146, 148, 151);
}/*position home, folio, contact */
nav ul li.right a {
margin-left: 600px;
}nav ul li.left1 a {
margin-left: 20px;
}nav ul li.center {
margin-left: 40px;
}nav ul li a {
text-decoration: none;
font-family: ‘HelveticaNeuel’;
color: rgb(146, 148, 151);
}nav a:hover {
color: rgb(164, 130, 46);
}nav ul li ul {
display: none;
font-size: 15px;
padding: 10px;
width: 800px;
}nav ul li:hover ul {
display: block;
position: absolute;
/*left: 0;*/
}nav ul li ul li {
padding: 10px;
}`Thanks,
Vicki
-
tried using current-menu-item and current-parent-item etc but none work
those are only generated if you use the WordPress
wp_nav_menu()
function.
http://codex.wordpress.org/Function_Reference/wp_nav_menuhttp://codex.wordpress.org/WordPress_Menu_User_Guide
a html menu will not automatically have ‘current’ CSS classes;
you would need to code extensive conditional statements to add those CSS classes to your menu items.This pseudo-classes example may help you:
a { outline: 0; text-decoration: underline; } a:link { color: #0099FF; } a:visited { color: #0099FF; } a:hover { color: #FFFF00; } a:active { color: #33FF66; }
just change the element to suit your needs.
- The topic ‘change color of menu item when on sub-menu page’ is closed to new replies.