简体   繁体   中英

Fade in / Fade out with hover function

Hi I would like to implement a Fade in / Fade out effect on my hover, How Can I do this cause I need to keep position of cursor for Text Displayed.

http://jsfiddle.net/u3pW8/34/

    $(function() {
    $("#static .wrapper").hover(function (e) {
        var parentOffset = $(this).parent().offset(); 
        var relX = e.pageX - parentOffset.left;
        $(this).children(".hidden-content").css("left", relX);
    });
});

Thx for help !

Use CSS3 transition:

.hidden-content {
    position: absolute;
    opacity:0;
    display:block;
    transition: opacity 0.2s ease;
}

.wrapper:hover .hidden-content {
    opacity:1;
}

http://jsfiddle.net/u3pW8/35/

I have made some changes to your code. This should work. I added this line among other things:

$(this).children(".hidden-content").fadeIn('slow');

http://jsfiddle.net/u3pW8/37/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM