如何平滑地淡化元素的高度?

How can I fade the height of an element smoothly?

我尝试在点击时淡出我的元素。但问题是,我想要它平滑,但高度在褪色后有点跳跃。是否有垂直平滑淡入淡出的选项?

这是一个堆栈片段:

$(".collapse-content").each(function() {
    if (!$(this).closest(".collapse-head").hasClass("active")) {
        $(this).hide();
    }
});

$('.collapse-head').hover(
    function() {
        $(this).find("blockquote").css({
            "color": "#000"
        });
    },

    function() {
        $(this).find("blockquote").css({
            "color": "#777"
        });
    }
);
$(".collapse-head").click(function() {
    $(".collapse-head").removeClass("active");
    $(this).addClass("active");
    $(".collapse-content").fadeOut("slow");
    $(this).find(".collapse-content").fadeIn("slow");
});
.collapse-head {
    cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="section-text mb-50 mb-sm-20">
    <div class="row collapse-head active" data-id="1">
        <div class="col-md-4">
        </div>
        <div class="col-md-4 collapse-title">
            <blockquote>
                <p>
                    A
                </p>
            </blockquote>
        </div>
        <div id="1" class=" col-md-4 col-sm-6 mb-sm-50 mb-xs-30 collapse-content" data-text="">
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
            sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
            rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </div>
    </div>
    <div class="row collapse-head" style="margin-top:20px" data-id="2">
        <div class="col-md-4">
        </div>
        <div class="col-md-4 collapse-title">
            <blockquote>
                <p>
                    B
                </p>
            </blockquote>
        </div>
        <div id="2" class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30 collapse-content" data-text="">
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
            sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
            rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </div>
    </div>
    <div class="row collapse-head" style="margin-top:20px" data-id="3">
        <div class="col-md-4">
        </div>
        <div class="col-md-4 collapse-title">
            <blockquote>
                <p>
                    C
                </p>
            </blockquote>
        </div>
        <div id="3" class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30 collapse-content" data-text="">
            Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
            sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea
            rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
        </div>
    </div>

</div>

还有一个fiddle:https://jsfiddle.net/8nqsdkvg/

@freedomn-m 说的对,但我认为问题出在.collapse content。这个怎么样?

$(".collapse-head").click(function() {
    $(".collapse-head").removeClass("active");
    $(".collapse-content").slideUp(1400);
    $(this).addClass("active");
    $(".collapse-content").fadeOut(1400);
    $(this).find(".collapse-content").fadeIn(1400);
});

我为 .collapse-content 添加 slideUp $(".collapse-content").slideUp(1400);

演示 here