当元素从DOM中移除时,过渡位置改变

Transition position change when element removed from DOM

本文关键字:位置 改变 元素 DOM      更新时间:2023-09-26

我有一个垂直的图像列表,用户可以通过点击它们来删除它们。一旦该元素从DOM中删除,该行中的下一个元素就会向上移动到它的位置。我如何为这个位置的改变做一个平滑的CSS过渡?

http://jsbin.com/dewiqilope/edit?html、js、输出

可以使用jQuery动画。

$('#element-selector').on('click', function () {
    $(this).slideUp(); // also you can use .fadeOut()
});