Forum Moderators: not2easy

Message Too Old, No Replies

Active state does not work any ideas

active state for pseudo classes

         

April_Floyd

11:09 am on Dec 7, 2007 (gmt 0)

10+ Year Member



Can anyone help and show which the following code does not work in the active state.


#services_nav a {
display:block;
width:146px;
height:37px;
margin: 0;
padding: 0;
background: url(../../images/nav_services.gif) 0 -1px no-repeat;
}

#services_nav a:visited {
display:block;
width:146px;
height:37px;
margin: 0;
padding: 0;
background: url(../../images/nav_services.gif) 0 -1px no-repeat;
}

#services_nav a:hover {
background-position: 0 -39px;
}

#services_nav a.active {
display:block;
width:146px;
height:37px;
margin: 0;
padding: 0;
background: url(../../images/nav_services.gif) 0 -1px no-repeat;
background-position: 0 -39px;
}

Thanks in advance

Xapti

4:02 am on Dec 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you have a.active, not a:active

April_Floyd

11:57 am on Dec 10, 2007 (gmt 0)

10+ Year Member



I have made the change, but it is still not working.

SuzyUK

3:34 pm on Dec 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi April_Floyd and welcome to WebmasterWorld!

are you aware that a:active (or a:focus for IE) only works when link is clicked on (or in focus) - usually a blink and you miss it

or are you looking to make a "navigation tab" stay highlighted when the page it pertains to is open?

try this for an example of how the

:active
and
:focus
work, you should see the red background only for a second or so after clicking the google link..

CSS:
#nav a {
display:block;
width:146px;
height:37px;
margin: 0;
padding: 0;
background: #eee;
}

#nav a:visited {background: #cfc;}
#nav a:hover {background: #dad;}
#nav a:focus, #nav a:active {background: #f00;}

HTML
<div id="nav"><a href="http://www.google.com">google</a><a href="#">home</a></div>

If it is the case that you would like an "active" tab to remain constant, depending on what page you're on - you either need to use a script to generate a CSS class name for the "active" link or you can use CSS body ID's combined with link classes, if you let us know which we can be more help.. there's a thread somewhere which explains how to do the latter

-Suzy

edited to add:
re: second method [webmasterworld.com]

[edited by: SuzyUK at 3:56 pm (utc) on Dec. 10, 2007]

April_Floyd

4:07 pm on Dec 10, 2007 (gmt 0)

10+ Year Member



I am looking to keep a navigation tab highlighted when the page is open.