jQuery opacity animation

前端 未结 3 1217
我在风中等你
我在风中等你 2020-12-16 10:13

I am making a website, and it allows users to change view options. I use jQuery to smooth animations for font changing. It fades the whole page out and back in again with th

相关标签:
3条回答
  • 2020-12-16 10:52

    You can use functions or something like this:

    $(document.body).animate({ opacity: 1/2 }, 1000);
    
    0 讨论(0)
  • 2020-12-16 10:53

    Why not use jQuery's built-in functions fadeIn and fadeOut?

    $('#font-classic').click(function(){
        $('body').fadeOut('normal', function(){
            $('body').fadeIn();
        }});
    });
    
    0 讨论(0)
  • 2020-12-16 10:53

    jQuery's .animate() takes values from 0 to 1.

    $(document.body).animate({opacity: 0}, 1000);
    $(document.body).animate({opacity: 1}, 1000);
    

    I'm sure that .animate() must call .parseFloat() (or something) on the values you're passing, which would make your 0% into 0 (which is correct), but your 100% into 100, which would be incorrect.

    0 讨论(0)
提交回复
热议问题