Reply
Make menu image change when clicked and stay.
Old 07-24-2008, 07:39 PM Make menu image change when clicked and stay.
Novice Talker

Posts: 5
I have a CSS menu that I am trying to get to work all the way. Right now the hover works fine.

Here is the markup:

Code:
/* IMAGE ROLLOVERS */

a.home-button {
width: 127px;
height: 44px;
background: url(images/home-button.png);
}

a.home-button:hover, #navigation a:focus {
width: 127px;
height: 44px;
background: url(images/home-button-hover.png);
}
When someone clicks on the link and is taken to the new page I want the home-button-hover.png to replace home-button.

The images are tabs, hover-button.png is blue and home-button-hover.png is white. If I have the hover stay when the link is clicked it will show the visitor what page they are on, since the link image will be white.

As you can see I tried to make this happen by applying a:focus to the hover css but that didn't work.

p.s. #navigation is the div that the menu is in.

So how do I do this? (make hover stay when clicked)

p.s.s. I have tried making a:active the hover image but it only lasts while it is clicked then when the new page comes up the link goes back to normal.
navd is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-24-2008, 09:03 PM Re: Make menu image change when clicked and stay.
LadynRed's Avatar
Super Moderator

Posts: 6,562
Location: Tennessee
The easiest way is to define a class for the 'selected' tab and add that to code, like this:

a.selected{background: url(images/home-button-hover.png);

Then in your html just do this: <a class="selected" href=.......">home</a>
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 07-24-2008, 09:09 PM Re: Make menu image change when clicked and stay.
Novice Talker

Posts: 5
Quote:
Originally Posted by LadynRed View Post
The easiest way is to define a class for the 'selected' tab and add that to code, like this:

a.selected{background: url(images/home-button-hover.png);

Then in your html just do this: <a class="selected" href=.......">home</a>

Thanks for your reply,

The only thing is that I am running off of wordpress so that won't work.
Wordpress is dynamic so that is going to be a little problem.
navd is offline
Reply With Quote
View Public Profile
 
Old 07-25-2008, 04:25 AM Re: Make menu image change when clicked and stay.
Novice Talker

Posts: 14
Name: Rik Weber
It's still possible in Wordpress, though you will need to know a bit of PHP:

http://wordpress.org/support/topic/140559

It involves using Wordpress' in-built functions 'in_category' and 'is_category'.
bobming is offline
Reply With Quote
View Public Profile
 
Old 07-25-2008, 09:53 AM Re: Make menu image change when clicked and stay.
Novice Talker

Posts: 5
Thanks for that it looks like exactly what I need. The only thing is I need this to work for pages not categories. Since I have an about and contact page these are the only menu images that are going to change. How can I change the php line to work for categories?
navd is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Make menu image change when clicked and stay.
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14251 seconds with 12 queries