Solved

Make current menu a certain color

Posted on 2014-10-15
10
115 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 23

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 23

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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... …
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

757 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