我的代码平滑效果

时间:2014-08-02 16:48:55

标签: javascript html css scroll easing

获得了此代码:

$(window).scroll(function () {
    if( $(window).width() < 924) {
    if ($(window).scrollTop() >= 100) {
        $('#normal_menu').css({
            height: '50px'
        })

        $('#logo img').css({
            height: '50px',
            width: '50px',
            top: '0',
            left: '15px' 
        });


    } else {
        $('#normal_menu').css({
            height: '120px'
        })

        $('#logo img').css({
            height: '80px',
            width: '80px',
            top: '20px',
            left: '0px' 
        });
    }
    }
});

工作正常。但现在我希望它顺利(轻松)。如何编辑此代码以使其顺利进行?

1 个答案:

答案 0 :(得分:1)

您应该将transition属性添加到所需元素:

#normal_menu,#logo img {
  transition: all .5s ease-in-out;
}