Solved

Make current menu a certain color

Posted on 2014-10-15
10
121 Views
Last Modified: 2014-10-16
I am trying to make the current menu a certain color.  It's not working.
The HTML
<ul>
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

Open in new window


The CSS
.ul.menu li.current a {
	color:#f8fb04;
	}

Open in new window

0
Comment
Question by:DS928
  • 4
  • 4
  • 2
10 Comments
 
LVL 26

Expert Comment

by:Dr. Klahn
ID: 40383689
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
<style>
	.current {
	background-color: #f8fb04;
	}
</style>
</head>

<body>

<ul>
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

</body>
</html>

Open in new window


Note that if you want the whole list to have the style and not just the individual list element, the style must be applied in the UL tag instead:

<ul class="current">

Open in new window

0
 

Author Comment

by:DS928
ID: 40383700
I just want the word home to be the different color.  I tried this but it still doesn't change the color.

.current {
	color: #f8fb04;
	}

Open in new window

and this
.current {
	background-color: #f8fb04;
	}

Open in new window

0
 
LVL 26

Expert Comment

by:Dr. Klahn
ID: 40383712
An easier way to do it than by applying a style:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>

<ul>
   <li><a href='#'><span><FONT COLOR="#F8FB04">Home</FONT></span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

</body>
</html>

Open in new window

0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 58

Expert Comment

by:Gary
ID: 40384445
God don't use FONT

http://jsfiddle.net/v3enLqyn/

Your menu, with a class added to the top menu
<ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>
</ul>

Open in new window


CSS
ul.menu li.current a {
	color:#f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384496
Yes.  I noticed that FONT changed the color but moved everything around as well.
Here is the HTML
<ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>

Open in new window


The CSS
.ul.menu li.current a {
	color:#f8fb04;
}

Open in new window


Still not changing the word "Home" to yellow.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40384516
You're not using the correct css

ul.menu li.current a {
	color:#f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384535
i tried that as well. Still not changing the color.

http://www.davidschure.com/index.html

<div id="container">
 <div id='cssmenu'>
   <ul class="menu">
   <li class="current"><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About</span></a></li>
   <li class='active has-sub'><a href='#'><span>Services</span></a>
      <ul>
         <li><a href='#'><span>Reputation Cleaner</span></a></li>
         <li><a href='#'><span>Search Engine Optimization</span></a></li>
         <li><a href='#'><span>Account Eraser</span></a></li>
      </ul>
   </li>
   <li><a href='#'><span>Corporate</span></a></li>
   <li><a href='#'><span>Estate Eraser</span></a></li>
   <li class='active has-sub'><a href='#'><span>Contact / Info</span></a>
      <ul>
         <li><a href='#'><span>Contact Us</span></a></li>
         <li><a href='#'><span>Terms and Conditions</span></a></li>
         <li><a href='#'><span>Privacy Policy</span></a></li>
   	  </ul>
</li>
 </div>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40384552
#cssmenu > ul > li.current > a {
    color: #f8fb04;
}

Open in new window

0
 

Author Comment

by:DS928
ID: 40384683
Bingo!  That worked!  Why?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40384684
It's more specific targetting, since you are using that to set the default colour you have to use the same targetting to change a color on a specific item
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding bootstrap to only Content page and NOT master page 1 51
Index on a Table 6 25
Add shadow behind div 5 25
CSS Style 8 23
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 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