Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected Menu 1

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
US
Hi,

I have Horizontal drop down menu on the top of my page. How do I indicate that a menu has been selected? ie, I want to highline the menu I have selected.

Thanks.
 
It works for IE but not for FF.

Here is what I have:

On jsp page:
<body id="home">

CSS:
body#home li.home a
{
color: #333333;
background-color: #FF9933;
}

What am I missing here?

Thanks.
 
..and here is me menu:

<ul id="nav">
<li class="home"><a href="#">Home</a></li>
<li class="Work"><a href="#">Work</a></li>
</ul>
 
Do you have a url of the site that you can post? Your question is very fragmented and not difficult to understand.

You state it works in IE, but not in FF. But I'm unsure of what it is.

One thing that I do notice right off the bat is that you've given your body tag an id. Since you should only have 1 body tag per page, there's not really a point to giving it an id. If your code looks like this, then the styles should apply in both IE and FF:
Code:
<style type="text/css">
body li.home a {
   color:#333333;
   background-color:#FF9933;
}
</style>
<body>
   <ul id="nav">
      <li class="home"><a href="#">Home</a></li>
      <li class="Work"><a href="#">Work</a></li>
   </ul>
</body>

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
kaht,

I'm trying to highline the menu I have selected on the menu bar.

It's my stupid mistake. I forgot #id in CSS style. I got it work now. Thanks.

Code:
body[b]#home[/b] li.home a {
   color:#333333;
   background-color:#FF9933;
}
</style>
 
I forgot #id in CSS style.

Actually, in your 3rd post you have the #id in the CSS style. But again, like I said it shouldn't matter because you shouldn't have more than one <body> tag in your page.

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
Then I don't know what I was missing. I played around with it and ... suddently it works. Thanks for your help anyways.
 
Err, kaht, the body id is a technique for highlighting the current page's entry in a menu. You give each page in your site a different id, and a matching class in the menu, like this:
Code:
<body id="home">
<h1>Home Page</h1>
<ul>
<li class="home"><a href="/">Home</a></li>
<li class="about"><a href="about.htm">About</a></li>
</ul>
</body>
Code:
<body id="about">
<h1>About Us</h1>
<ul>
<li class="home"><a href="/">Home</a></li>
<li class="about"><a href="about.htm">About</a></li>
</ul>
</body>
Then you can put this in your style sheet:
Code:
#home .home,
#about .about {
   color: red;
}
Personally, I prefer to use SSI to build the menu dynamically, including a [tt]class="current"[/tt] in the current menu item. However, if that technique's not available to you, this one works pretty well.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
I see chris, that's a good point and one that I had not thought of before - I see how an id on the body tag could be useful.

In all fairness of the OP's question, the id on the body tag would be irrelevant to this particular situation. The 1 style provided should be applied with the #id identifier or not. And it most certainly should not make a difference between it breaking in FF and working in IE.

-kaht

[small]How spicy would you like your chang sauce? Oh man... I have no idea what's goin' on right now...[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top