CSS3 equivalent to jQuery slideUp and slideDown?

前端 未结 10 1121
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 08:12

My application is performing poorly with jQuery\'s slideDown and slideUp. I\'m looking to use a CSS3 equivalent in browsers which support it.

Is it possible, using C

10条回答
  •  借酒劲吻你
    2020-12-04 08:57

    I changed your solution, so that it works in all modern browsers:

    css snippet:

    -webkit-transition: height 1s ease-in-out;
    -moz-transition: height 1s ease-in-out;
    -ms-transition: height 1s ease-in-out;
    -o-transition: height 1s ease-in-out;
    transition: height 1s ease-in-out;
    

    js snippet:

        var clone = $('#this').clone()
                    .css({'position':'absolute','visibility':'hidden','height':'auto'})
                    .addClass('slideClone')
                    .appendTo('body');
    
        var newHeight = $(".slideClone").height();
        $(".slideClone").remove();
        $('#this').css('height',newHeight + 'px');
    

    here's the full example http://jsfiddle.net/RHPQd/

提交回复
热议问题