Forum Moderators: not2easy

Message Too Old, No Replies

CSS based menu

How do you get "active" to stick

         

Stephen Tiller

3:00 pm on Oct 4, 2006 (gmt 0)

10+ Year Member



Hi all

I have a CSS based Menu for a new website I am working on. Everything is fine with Link, Visited, Hover but not active.

What I want to do is when the user has clicked on a link I would like that link to be in the "down" state so the user clearly knows what page he is on, plus the "down" state is incorporated into the web page design.

When I test my pages and select a link the "down" state appears but when I am on the selected link page the link has reverted to it's original state which I don't want.

I guess I can manipulate each page and insert an appropriate image for that page so the user sees a "down" state but I would like to know if this is possible to do using text only and without using images.

Regards

Steve

penders

4:03 pm on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi Steve, as you've found, "The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it." (W3C) It doesn't stay 'active'.

You need something within each page to trigger the 'down' state on a particular menu item, and then you can write the corresponding CSS.

One way to provide this 'trigger' is to simply have an id on the <body> tag. ie. <body id="homepage"> Each page has its own unique body ID. And also assign each menu item its own unique ID. You can then write the appropriate CSS... If BodyID="homepage" and MenuID="homepage_link" then "homepage_link" is in 'down' state etc. (psuedo code)

This technique has been discussed a few times, SuzyUK explains it well in this thread:
[webmasterworld.com...]

Stephen Tiller

11:54 am on Oct 5, 2006 (gmt 0)

10+ Year Member



Thanks, that was just what I needed!

Does this work on all browsers? I am on Internet Explorer 7.0 and don't usually test for other browsers.

Also I have another question regarding CSS based menu. Now that I have implemented this technique is it possible to combine a text based image such as this with an image. For example if I inserted an arrow image within my border it would really finish my design off.

Thanks

Steve

icantthinkofone

12:21 pm on Oct 5, 2006 (gmt 0)

10+ Year Member



Never, ever initially design and test using Internet Explorer of any version. IE, including the new IE7, is years behind web standards and is broken. Code written in IE stands too much chance of being faulty and possibly not working in ANY other browser.

Always, always use a modern browser, such as Firefox/Opera/Safari/anything but IE. Then your code can be adjusted for IEs quirks and bugs if it doesn't work in the first place. In addition, IE7 does not work the same as IE6.

Stephen Tiller

1:06 pm on Oct 5, 2006 (gmt 0)

10+ Year Member



My thinking was if it worked in IE 7 my design and CSS would work in other and older browsers, I have just tested it in Firefox and it was okay. Also I work in a Microsoft affiliated company and I have little pressure to design for other browsers but for me personally it is important so I take your advice on board.

Regards

Steve

penders

2:29 pm on Oct 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...is it possible to combine a text based image such as this with an image. For example if I inserted an arrow image within my border it would really finish my design off.

Yes it's possible, in a few ways.... It may be easier to just have a 2nd (or 3rd?) background-image which is similar to the previous, but just has the additional 'arrow' on it.

OR, if the background-image is on your <li> element, you could have the 'arrow' background on your <a> element which is inside and on top of your <li> element. The 'arrow' background would need to be largely transparent (a gif or png) for the background on your <li> element to show through.

...if it worked in IE 7 my design and CSS would work in other and older browsers...

It could work in IE7 and not work in IE6....!