Expand div on click with smooth animation

前端 未结 5 1427
难免孤独
难免孤独 2020-12-28 23:15

I am trying to expand a div with speed/smooth animation. Right now div expands with sudden change, my requirement is to give smooth animation while expanding.

Fiddl

5条回答
  •  梦毁少年i
    2020-12-29 00:04

    I have some solution for you, But in that case you can not set hieght to auto, you can do following, replace you jquery code with these :-

    $('.click1').find('a[href="#"]').on('click', function (e) {
        e.preventDefault();
        this.expand = !this.expand;
        $(this).text(this.expand?"Hide Content":"Read More");
    
        $(this).closest('.click1').find('.smalldesc, .bigdesc').animate({
            "height": "400px"
        }, "slow");  
    });
    

    It may help you.

提交回复
热议问题