0

我正在寻找的是让我的容器在点击时调整大小。

容器内有 2 个以不同高度向下滑动的面板。我需要容器来监听切换功能并在需要时调整大小。

这是到目前为止的代码......

$(document).ready(function() {

    var content = $("#content_container");  
    var childHeight = $('.panel-container').height();

    if (content < childHeight) {
        $(content).css("height", 657 + "px");
    }

    else {
        $(content).css("height", "auto");
    }

});

PS。我是 jQuery 的新手!!

4

1 回答 1

0

你可以用下面这样的东西,我不确定这是否是你想要的,但你可以把它弄乱,让它变成你想要的样子;

$(document).ready(function() {

    $("#content_container").toggle(
        function() {
            $(this).animate({height: 657}, 200);
        }, 
        function() {
            $(this).animate({height: 200}, 200);
        }
    );

});

一个工作示例http://jsfiddle.net/CarlG/x6yLj/2/

于 2013-05-19T12:58:42.090 回答