Solved

Sub navigation colors

Posted on 2013-11-08
3
142 Views
Last Modified: 2013-11-11
Hello, I'm modifying a .css and I want to be able to have the .current state for a sub nav to be a different color than the .current state for a parent nav. Below is the hover color for a sub and the .current color.

#leftcol ul.menu ul li a:hover{
      color: #872835;
}

.menu .current a span {
  color: #EEC015;
}

What is the code for making the .current a span for a sub nav?
0
Comment
Question by:DancingFighterG
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39635594
You don't have enough info to really help so I am going to improvise.  I am not using span's in this example http://jsbin.com/ukUrIxa/1/edit?html,css,output

Leave the #leftcol out of your css for the menu unless you have a class menu someplace else that requires different styles.  

.menu a{color:black;}
.menu .current a{color:red;}
.menu .current ul a{color:green;}

Open in new window

  <div id="leftcol">
     <ul class="menu">
          <li><a href="#">Item 1</a></li>
          <li class="current"><a href="#">Item 2</a>
               <ul>
                     <li><a href="#">Item 2.1</a></li>
                    <li><a href="#">Item 2.2</a></li>
               </ul>
          </li>
       <li><a href="#">Item 3</a>
               <ul>
                     <li><a href="#">Item 3.1</a></li>
                    <li><a href="#">Item 3.2</a></li>
               </ul>
          </li>
    </ul>
</div>

Open in new window

0
 

Author Comment

by:DancingFighterG
ID: 39639141
Here is all the section related to the menu look:

#leftcol ul{
      list-style:none;
}

#leftcol ul.menu li{
      line-height:20px;
}

#leftcol ul.menu ul li a span{
      padding-left: 20px;
}

.menu li a, .menu li a:link {
    background: url("../images/menu_arrow.gif") no-repeat scroll left top transparent;
    color: #fff;
    display: block;        
    font: bold 13px/33px verdana;
    height: 33px;
    padding-left: 20px;
    position: relative;
    text-align: left;
    text-decoration: none;
}

.menu li a:hover{
      color: #EEC015;
}

#leftcol ul.menu ul li a:hover{
      color: #872835;
}

.menu .parent ul li a {
      font: 12px/33px Verdana;
      background: url("../images/submenu.gif") no-repeat scroll left top transparent;
}

.menu .current a span {
  color: #EEC015;
}

________________________________________________________________________________

Overall the following code puts the correct color for the submenu items as a hover:

#leftcol ul.menu ul li a:hover{
      color: #872835;
}

With that being said when someone clicks on the submenu I need the submenu on click to stay the same color as the hover color. The following code is handling the coloring for all menus that are clicked

.menu .current a span {
  color: #EEC015;
}
0
 

Author Comment

by:DancingFighterG
ID: 39639296
Ok I figured it out
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now