Grow your CSS skills. Land your dream job.

How to solving : CSS selector “:active” not working ?

  • # July 15, 2012 at 5:43 am

    I’m very confused, because :hover selector was working normaly, but active not working.
    The code:

    ::CSS::
    #working

    #selec:hover{background-color:blue;}

    #not work

    #selec:active{background-color:red;}

    ::PHP::

    ">
    < ?php $name;?>

    Anyone can help me? Thank you

    # July 15, 2012 at 7:07 am

    JuanLie, you really need to better explain the problem and give some code or link.

    I’ll take a guess and assume you think that the active psuedo class should work for navigation when on a certain page – it doesn’t. Active is when the link or element is actually being selected, like when you’re mouse clicking on a link.

    If this is true, then simply use php to add an active class to the link or div in question

    # July 15, 2012 at 7:18 am

    I guess if you do it like this it won’t work:
    http://codepen.io/AntonNiklasson/pen/21/2

    If that’s you problem, put the :active below the :hover.

    # July 15, 2012 at 8:42 am

    @wolfcry911 : would you please to solve my problem, please?
    @AntonNiklasson : its same, not working, I have gave up for this problem :(.

    # July 16, 2012 at 10:05 am

    I have had this problem before. I believe you need to order them correctly. link, active, hover, visited. Hover will work by itself, but active and visited will only work if it follows link.

    # July 16, 2012 at 2:04 pm

    Yes, the order in which you style the links matters.

    But I thought the recommended order is link, visited, hover, focus, active (I remember it with Lord Vader’s Handle Formerly Annakin). Am I wrong? Has that changed?

    # July 20, 2012 at 8:54 pm

    xxx

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".