jquery animate line height - possible?

前端 未结 1 1415
甜味超标
甜味超标 2021-01-21 21:47

quick question about the the animate property in jquery, Is it possible to animate

I cant figure out how? here is my html

1条回答
  •  有刺的猬
    2021-01-21 22:34

    Here you go, it was your line-height in animate function it should have been 'line-height'

    $(function(){
       $('nav').data('size','big');
    });
    
    $(window).scroll(function(){
        var $nav = $('nav');
        var $a = $('nav > a');
        if ($('body').scrollTop() > 0) {
            if ($nav.data('size') == 'big') {
                $nav.data('size','small').stop().animate({
                    height:'40px',
                    'line-height':'40px'
                }, 300);
                $a.data('size','small').stop().animate({
                    height:'20px'
                }, 300);
            }
        } else {
            if ($nav.data('size') == 'small') {
                $nav.data('size','big').stop().animate({
                    height:'100px',
                    'line-height':'40px'
                }, 300);
                $a.data('size','big').stop().animate({
                    height:'40px'
                }, 300);
    
    
            }  
        }
    });
    

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