css transition doesn't work if element start hidden

后端 未结 5 2053
感情败类
感情败类 2020-11-29 12:47

I have 2 divs, one of them is hidden via display:none;. Both have the same css transition on the property right.

If I change t

5条回答
  •  鱼传尺愫
    2020-11-29 13:15

    Personally I would check to see if the element is visible after making it show. Then continue on through the jQuery.

    Like this: https://jsfiddle.net/789su6xb/

    $('button').on('click',function(){
    
        var b = $('.b');
        b.show();
    
        if(b.is(":visible")) {
            $('.b').css('right','80%');
            $('.a').css('right','80%');
        }
    
    });
    

提交回复
热议问题