Search code examples
htmlcsscss-animationspseudo-classkeyframe

CSS :hover issue


I got this problem with my pseudo classes, i have a dropdownlist with anchor taggs in it, like so:

<div class="btn-group" id="dropdown-wrapper">
    <a href="" data-toggle="dropdown" id="toggle-dropdown">Het 10-stappenplan <i class="fa fa-caret-down"></i></span></a>
    <ul class="dropdown-menu">
        <li><a class="menulink" href="?p=stap1">Stap 1 - Een oriënterend gesprek</a></li>
        <li><a class="menulink" href="?p=stap2">Stap 2 - De AirAware Quickscan</a></li>
        <li><a class="menulink" href="?p=stap3">Stap 3 - Uw ambitie, wensen en eisen</a></li>
        <li><a class="menulink" href="?p=stap4">Stap 4 - Ons Advies</a></li>
        <li><a class="menulink" href="?p=stap5">Stap 5 - Uw keuze</a></li>
        <li><a class="menulink" href="?p=stap6">Stap 6 - Het ontwerp en de planning</a></li>
        <li><a class="menulink" href="?p=stap7">Stap 7 - De realisatie</a></li>
        <li><a class="menulink" href="?p=stap8">Stap 8 - Het beheer en onderhoud</a></li>
        <li><a class="menulink" href="?p=stap9">Stap 9 - De periodieke controle</a></li>
        <li><a class="menulink" href="?p=stap10">Stap 10 - Sale &amp; Leaseback</a></li>
    </ul>
</div>

then i got my CSS:

.links .dropdown-menu li a.menulink{
    padding: 8px 5px 8px 5px;
    color: white;
    width: 260px;
}

.links .dropdown-menu li a.menulink:hover {
    animation: textColorfade 2s ease forwards !important;
    -webkit-animation: textColorfade 2s ease forwards !important;
    color:black;
    padding: 8px 5 8px 20px !important;
    background-color: white !important;
}

@-webkit-keyframes textColorfade {
    from { 
    color: white !important; 
    padding: 8px 5px 8px 10px !important;
    }

    to { 
    color: black !important; 
    padding: 8px 5px 8px 10px !important;
   }
   }

for some reason when the link is visited it doesnt do the keyframe animation anymore, i believe neither when its active, can anyone explain me why and maybe how i can fix this problem


Solution

  • Links cannot have multiple pseudo-classes / states so

    a:visited:hover {
    }
    

    is not possible.

    I suspect what you are after is a transition not an animation.