Solved

Make current menu a certain color

Posted on 2014-10-15
10
117 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 24

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 24

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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
alert before form submission 6 30
.php tree directory? 5 55
Form Processing in PHP 11 30
Configuring a checkbox in CSS and php 18 30
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

911 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

20 Experts available now in Live!

Get 1:1 Help Now