Search code examples
csshoverfade

img:hover transition not matching given variable


Ok so I am trying to create an inversion effect on hover of the silhouette, I've gotten all the CSS to change accordingly and used some minor JS to replace the image but the fading transition for the image goes much quicker than everything else. Even when setting the time to far more than it should be it does not seem to effecting it.

You should be able to see my style sheet at the link below, it's pretty tiny but I figured I'd let you guys see it all instead of the specific lines I'm talking about because I believe there could be a conflict.

#shadow {
    width:33%;
    -webkit-transition: all 2.2s ease-in-out;
    -moz-transition: all 2.2s ease-in-out;
    -o-transition: all 2.2s ease-in-out;
    transition: all 2.2s ease-in-out;   
}
#shadow:hover {
    -webkit-transition: all 2.2s ease-in-out;
    -moz-transition: all 2.2s ease-in-out;
    -o-transition: all 2.2s ease-in-out;
    transition: all 2.2s ease-in-out;   
}

Solution

  • Your code is not working on :hover because you simply change source of img. CSS has nothing to do with it.

    You can place image in a div and set other image as div's background-image. Then on hover just reduce opacity to 0.

    Demo

    EDIT

    In future you can use CSS filter property. Currently its supported by just -webkit. It'll be as simple as

    img {
        filter: invert(100%);
    }
    

    and you're done. But currently its just

    img {
        -webkit-filter: invert(100%);`
        /*-moz -o -ms all are unimplimented*/
    }
    

    Proof of concept (Use chrome or safari to see the effect)

    +filter(W3C)