/    Sign up×
Community /Pin to ProfileBookmark

Link: hover ok and active will not work

Hallo,

i use some valid CSS code and like to have this diff. colors in my menu. I use this style for the links:

[code=php]#nav1 a:link, #nav1 a:visited {
display:block;
width:80px;
color: #3300FF;
text-decoration: none;
background-color: transparent;
}
#nav1 a:hover, #nav1 a:active {
color: #333333;
background-color: transparent;
}[/code]

the hover, link and visited is OK but the active will not work, any idea?

to post a comment
CSS

50 Comments(s)

Copy linkTweet thisAlerts:
@ray326Sep 03.2004 — Since you have hover and active the same, how can you tell active isn't working?
Copy linkTweet thisAlerts:
@olafauthorSep 03.2004 — i just created an extra style for active but the color doesn't change like in the grouped style...
Copy linkTweet thisAlerts:
@artemisSep 03.2004 — [font=technical][size=3]which browser is this problem occuring in?[/size][/font]
Copy linkTweet thisAlerts:
@PhillMcSep 03.2004 — You have to define the psuedo-classes in a particular order, seperately; like so:

A:link

A:visited

A:hover

A:active

?
Copy linkTweet thisAlerts:
@olafauthorSep 04.2004 — artemis,

it happens in all browsers i have tested. Try it by yourself (use the link in my signature)

PhillMc,

like you see above the order is OK... i tried it also in seperate classes.
Copy linkTweet thisAlerts:
@artemisSep 04.2004 — [font=technical][size=3]when you say the [i]:active[/i] will not work, what exactly happens. The active refers to what the link does when you click it therefore if the link were hovered over, as is most likely if someone were clicking it, then the link would not change.



Do you wish the link to change or is it changing when you dont want it to?[/size]
[/font]
Copy linkTweet thisAlerts:
@olafauthorSep 04.2004 — maybe you can check this too;

http://css.maxdesign.com.au/listamatic/horizontal02.htm

what about the "active" id for the first li element? is this the secret?
Copy linkTweet thisAlerts:
@David_HarrisonSep 04.2004 — [i]Originally posted by PhillMc [/i]

[B]You have to define the psuedo-classes in a particular order[/b][/quote]
True so far.

[i]Originally posted by PhillMc [/i]

[B]seperately[/b][/quote]
Oh, head on collision with a fridge!!! :eek: ?

Here's an example script that shows all of the link psuedo classes working. Incidentally, here is the correct order:[list]
  • [*]a
  • [*]a:link
  • [*]a:visited
  • [*][b]a:focus[/b]^ note the focus, don't forget the focus
  • [*]a:hover
  • [*]a:active
  • [/list]
    You should always specify the a styles for browsers that don't support psuedo classes (if you include your styles I don't suppose it really matters, I do it anyway though).
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — I only forgot the flipping attachment didn't I?

    [upl-file uuid=00727317-94e3-40ff-8b18-6fe2ff3c7f5b size=19kB]css image rollover.zip[/upl-file]
    Copy linkTweet thisAlerts:
    @PhillMcSep 04.2004 — [i]Originally posted by lavalamp [/i]

    [B]Oh, head on collision with a fridge!!! :eek: ? [/B][/QUOTE]


    :p ?

    Learn something new everyday. ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — Hallo lavalamp,

    thanks for helping again...

    I'm sorry the attachement is not valid (i'got something what you have posted before)
    Copy linkTweet thisAlerts:
    @PhillMcSep 04.2004 — Rename it with a zip extension; it'll open. ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — never thought that this is possible....

    after renaming i got an old attachement from lavalamp (i think its a bug in the forum-software)
    Copy linkTweet thisAlerts:
    @PhillMcSep 04.2004 — Not really.

    Sometimes file extensions get neglected in the download process. ?
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — Actually I think it's a bug with Firefox, sometimes it doesn't download files properly with spaces in the name.

    Incidentally, it only screws up on this particular web-site, and has only been doing it for the past few months.

    On reflection it's probably something screwed up with these forums. ?

    Anywho, here's the script again:

    [upl-file uuid=7af8cfcc-8d9f-474f-8afa-2c38dc9b3bd6 size=19kB]css.zip[/upl-file]
    Copy linkTweet thisAlerts:
    @PhillMcSep 04.2004 — lol

    I was trying to keep it simplified. ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — hallo lavalamp,

    thanks for the example but i cannot solve the problem:

    [code=php]#nav1 a, #nav1 a:link, #nav1 a:visited {
    display:block;
    width:80px;
    color: #3300FF;
    text-decoration: none;
    background-color: transparent;
    }
    #nav1 a:focus, #nav1 a:hover {
    color: #333333;
    background-color: transparent;
    }
    #nav1 a:active {
    color: #666666;
    background-color: transparent;
    }[/code]


    check my site and nothing its changing after i clicked one of the menu buttons...
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — Seems to be working for me:

    [upl-file uuid=4d35a88c-2aa3-46c9-95b5-bf439ac40b53 size=3kB]faq.jpg[/upl-file]
    Copy linkTweet thisAlerts:
    @NeczySep 04.2004 — is that image named fag? :p
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — [i]Originally posted by Neczy [/i]

    [B]is that image named fag? :p[/B][/QUOTE]
    Er, no. ?
    Copy linkTweet thisAlerts:
    @NeczySep 04.2004 — [i]Originally posted by lavalamp [/i]

    [B]Seems to be working for me:



    Attachment: faq.jpg[/B]
    [/QUOTE]


    I thought that "faq.jpg said fag.jpg" i thought it was funny...but now that it says faq it isnt funny ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — it's weird (not the faq.jpg) i removed the cache and revisited the page and don't get an active state...

    is it the location where i live?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — strange is that it works for the page numbers on the newspage...?
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — The only styles that are applying to the page numbers on the news page are these:a:link {
    color: #3300FF;
    text-decoration: none;
    }
    a:visited {
    color: #3300FF;
    text-decoration: none;
    }
    a:hover {
    color: #333333;
    text-decoration: none;
    }
    a:active {
    color: #333333;
    text-decoration: none;
    }
    I don't see a problem there.

    Actually I do, the styles should look like this:a, a:link, a:visited {
    color: #3300FF;
    text-decoration: none;
    }
    a:focus, a:hover, a:active {
    color: #333333;
    text-decoration: none;
    }
    ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — you are absolutly right this should be grouped. But can you explain why the "general" styles for the links are working and the styles for the navigation not?
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 04.2004 — Both sets of styles are working, but just strangely not for you.

    Try hitting Ctrl+F5 (forced refresh). That should re-download every single file and hopefuly get it working again, although clearing the cache should have done that anyway.

    Are you using Opera by any chance? Opera is notoriously bad for caching EVERYTHING.
    Copy linkTweet thisAlerts:
    @PhillMcSep 04.2004 — [i]Originally posted by lavalamp [/i]

    [B]Both sets of styles are working, but just strangely not for you.



    Try hitting Ctrl+F5 (forced refresh). That should re-download every single file and hopefuly get it working again, although clearing the cache should have done that anyway.



    Are you using Opera by any chance? Opera is notoriously bad for caching EVERYTHING. [/B]
    [/QUOTE]


    I wouldn't doubt it; Opera has trouble letting go of the cache. It's part of it being the "fastest browser in the world", according to the site. lol
    Copy linkTweet thisAlerts:
    @olafauthorSep 04.2004 — Sorry, i don't go into the opera...?

    I checked it with IE and removed the css file manually without a result. I cannot believe that you all see it like it have to be....?
    Copy linkTweet thisAlerts:
    @Stephen_PhilbinSep 04.2004 — Anchors have a focus pseudo class? How very groovalicious! ?

    Oh and Olaf, have you checked that it's not your server that's the problem? One of the servers I work on is a real pain in the arse to work on. I think it's something to do with some DNS thing somewhere. If I make an alteration to an existing file it can take anything up to 30 hours for the changes to be sent (if you have viewed the page previously). However it'll dish out new files no probs.
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — yes i can remember something like this 2 years before, but i have this problem on my local machine too. But I will do test with copies...
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — after creating a new css-file and page I can't see the result...:mad:

    Lavalamp,

    if you see the right states then it should be OK...and I cant't see an sctive state on your site...

    but i see active states on zeldman's site (the navigation in the right colomn)
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 05.2004 — [i]Originally posted by olaf [/i]

    [B]I cant't see an sctive state on your site...



    but i see active states on zeldman's site (the navigation in the right colomn) [/B]
    [/QUOTE]
    On my site I've set all of the :focus, :hover and :active states to look the same.

    Are you sure that the active state is not ocurring? Not to patronise but you know you have to click the link right?

    Also the colours you have chosen for the :hover and :active are very similar...
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — click the link right? right button?

    ?

    what I see on zeldaman's site is the link in a diff. collor if the choosen page is active.

    I don't know why it is like this he uses this for the link colors...
    [code=php]a:link, a:visited {
    font-weight : bold;
    text-decoration : none;
    color: #785;
    background: transparent;
    }

    a:hover {
    font-weight : bold;
    text-decoration : none;
    color: #530;
    background: transparent;
    }

    a:active {
    font-weight : bold;
    text-decoration : none;
    color: #785;
    background: transparent;

    }[/code]
    Copy linkTweet thisAlerts:
    @Paul_JrSep 05.2004 — [i]Originally posted by olaf [/i]

    [B]what I see on zeldaman's site is the link in a diff. collor if the choosen page is active.[/B][/QUOTE]

    You mean how the "about" link is different from the rest of the links when you're on the "about" page? How, when you're on the main page, the "the daily report" link is different from the rest of the links, too?
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — hallo,

    i didn't check the top navigation (this navigation is with images, i mean the same like you describe but for the right colomn navigation.
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — Maybe this will help...

    what is the reason for using a id inside a link-tag?
    [code=php]<a href="/designer/" id="n_designer" accesskey="D" title="Here I am, this is me...">The <span class="underline">D</span>esigner</a>[/code]
    Copy linkTweet thisAlerts:
    @Paul_JrSep 05.2004 — Ah, I see what you mean (I went to the contact page, and the corresponding link in the sidebar was different from the rest). This can't be done with just CSS. You must, either by hand or through some sort of server-side scripting, assign an ID or class to the link that corresponds with the current page, and then apply the necessary styles to that ID or class.
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — Ok, then it looks like that I misunderstood the active state...?
    Copy linkTweet thisAlerts:
    @olafauthorSep 05.2004 — Paul,

    i used some "smart php code" to solve it, are you sure that this is the only way?
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 05.2004 — The active state occurs when you're actually clicking the link (ie: when the link is active).

    CSS can't detect whether the href of a link leads to the same page or not.

    A "smart server-side language" gimmick is definately the easiest way, the second easiest way would be to go round to any links you want to be "active" on a particular page and give them all a class, then style that class accordingly.
    Copy linkTweet thisAlerts:
    @olafauthorSep 06.2004 — Hallo,

    my mistake... i thought i saw something else before.

    the second easiest way would be to go round to any links you want to be "active" on a particular page and give them all a class[/QUOTE]

    this is a really "hard" way, for sure its possible.

    Thank you all.
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 06.2004 — [i]Originally posted by olaf [/i]

    [B]this is a really "hard" way, for sure its possible.[/B][/QUOTE]
    Yeah, but it's still the second easiest. ?
    Copy linkTweet thisAlerts:
    @Ness_du_FratSep 07.2004 — [i]Originally posted by lavalamp [/i]

    [B]The active state occurs when you're actually clicking the link (ie: when the link is active).



    CSS can't detect whether the href of a link leads to the same page or not.

    A "smart server-side language" gimmick is definately the easiest way, the second easiest way would be to go round to any links you want to be "active" on a particular page and give them all a class, then style that class accordingly. [/B]
    [/QUOTE]

    Yeah, but how do you do that with frames ?

    Do you have to put the CSS in the frameset page ? ? I'm really confused... As a matter of fact, I'm trying to get exactly the same thing, and I tried the class thing, but no way it would work in a page with frames, where the navigation is on a frame, and the mainpage on another... ?

    Any solution ?
    Copy linkTweet thisAlerts:
    @olafauthorSep 07.2004 — this thread is table- and frameless

    ?
    Copy linkTweet thisAlerts:
    @Ness_du_FratSep 07.2004 — oups, sorry...

    But if I find a solution, am I allowed to post it here ? ?

    BTW, do you accept Javascript ? Because I have some hints on how to do this, which would correspond to what you want, but it would include a mini mini tiny bit of Js.... ^__^
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 07.2004 — The only way to achieve this effect with frames would be a bit of a messy JavaScript solution that compares the URL of a page with the links on it.

    Frames are now, and have been for some time, depreciated. That goes for iframes too.

    They have been removed completely from the newest markup specification (XHTML 1.1), however they are set to make a comeback in XHTML 2.0 as xframes. I don't know what makes them different, but for now frames are generally frowned upon for a couple of reasons:

  • * They are inaccessible to some non-graphical browsers.

  • * If you bookmark a page that uses frames then come back to it, you're taken to a completely different page.


  • While I'm ranting, using tables for layout is also bad becuase they are very inaccessible to some users. Use CSS and semantically correct markup as a base for a layout. ?
    Copy linkTweet thisAlerts:
    @Ness_du_FratSep 07.2004 — But... but... Okay, everything you said is right, but... I just love frames !!!! And iframes are my best friends !!!!

    How can you make something without them ? Except maybe, by messing around with padding, margings, float and dtuff like that... Or then, you have just 50 different pages on your website !!!!

    If you have a good solution, I would be glad to hear it...

    Here is my website : http://enfantsdelo.free.fr

    It's made with frames... Now, how could I make it without frames ? ( especially the frameset dependant css... )

    Oh, Olaf, for your problem, I have a solution....

    [URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=43747]Here it is[/URL]

    Tell me if it helped !!! For me, it worked just great !!

    NesS ( the frame-loving girl ? )
    Copy linkTweet thisAlerts:
    @David_HarrisonSep 08.2004 — Well your seb-site could easily be made with CSS, the only thing of concern is that 100% of the page height is not something that can be done with CSS since the page should only be as high as the content on it.

    Also, you wouldn't need two different versions of the site because a CSS based layout could flex with the width of the page.

    Ditch the tables and frames.

    Please.

    Look I'll help you, get this book :-

    Elizabeth Castro's HTML for the World Wide Web with XHTML and CSS
    Copy linkTweet thisAlerts:
    @olafauthorSep 08.2004 — Ness,

    believe me, first i thought that frames are the solution, but now i would never use them again... frames and iframes are so bad for search engines and diff. browsers. There are so much bad points and i think this thread is not the right place to discuss this.

    About tables: I changed my thoughts about tables completly after i read this:

    http://www.hotdesign.com/seybold/.

    Use CSS like lavalamp said and maybe you can combine this with a little bit of PHP or other server side language.

    Success.
    ×

    Success!

    Help @olaf spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.8,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...