Christoph Kolb
Christoph Kolb

Reputation: 3

CSS color-transition not working on :hover

Another question with using CSS.

I would like to have the header's background-color transitioning from it's current to another when hovering (due to multiple sites having different colors).

I made a CSS-transition-animation for it, but it doesn't seem to be working. What am I doing wrong?

        #header
    {
    background-color: #3cff9c;
    float: left;
    text-align: center;
    width: 100%;
    }

    #header:hover
    {           
    /*Animation*/
    -webkit-animation: colorChange_blue 1s; /* Safari, Chrome, Opera*/
    -moz-animation: colorChange_blue 1s; /*Firefox*/
    animation: colorChange_blue 1s; /*Standard*/

    /*Safari, Chrome, Opera*/
    @-webkit-keyframes colorChange_blue 
    {
    from 
        {background-color;}
    to   
        {background-color: #008c74;}
    }

    /*Firefox*/
    @-moz-keyframes colorChange_blue
    {
    from
        {background-color: currentColor;}
    to
        {background-color: #008c74;}
    }

    /*Standard*/
    @keyframes colorChange_blue
    {
    from
        {background-color: currentColor;}
    to
        {background-color: #008c74;}
    }
}

Upvotes: 0

Views: 1970

Answers (1)

MMachinegun
MMachinegun

Reputation: 3074

how about solving it without keyframes and just standard hover with transitions?

#header {
    height: 50px;
    width: 100px;
    background-color: #3cff9c;
    transition: background-color 1s;
}

#header:hover {           
    background-color: #008c74;
}
<div id="header"></div>

Upvotes: 1

Related Questions