Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FadeIn/out effect on hover

I have a FadeIn/Out effect on my page for a couple of Social logos.

It seems they work fine but the initial fade in wont work untill i hover over them.

How can i make the fade in function work when the page is loaded?

<script type='text/javascript'>
    $(document).ready(function()
    {
        $("img.a").hover(function() 
        {
            $(this).stop().animate({"opacity": "1"}, "fast");
        },
        function() 
        {
            $(this).stop().animate({"opacity": "0.5"}, "fast");
        });
    });
</script>

The Page:

www.tranceil.fm

like image 300
TonalDev Avatar asked Jul 17 '26 03:07

TonalDev


1 Answers

I know you need a jQuery solution but why to use it if you can do it with CSS?

img.class {
   opacity: .5;
   transition: opacity 2s;
   /* Transitions will take care of the smooth effect */
   -moz-transition: opacity 2s; /* Firefox 4 */
   -webkit-transition: opacity 2s; /* Safari and Chrome */
   -o-transition: opacity 2s; /* Opera */
}

img.class:hover {
   opacity: 1;
}

Note: Am not using rgba because it is just an image

For IE support you can use CSS3 Pie

If you still want to stick to jQuery, am not that good with it but I guess you can set initial opacity for your social icon by simply defining it in your CSS

img.a {
   opacity: .5;
}
like image 144
Mr. Alien Avatar answered Jul 18 '26 15:07

Mr. Alien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!