jQuery-浮动部分更改高度大小

时间:2018-07-25 10:40:10

标签: jquery html

我创建了两面的页面。在右侧,我具有带有引导程序面板的浮动部分,可以将其拖动到右侧部分。

好吧,问题在于右侧部分没有获得完整的页面高度(从搜索区域到页面页脚。

我希望浮动部分的高度(在右侧)将始终是其最大高度(在搜索部分和页脚之间),但是-浮动部分可能包含很多面板,因此必须在其中滚动...

非常感谢您的帮助

CSS

#res-wrap {max-height: 500px;  overflow-y: auto;    position: fixed;  }
.change-div-canvas {top: -30px; }

当前的JS

$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    var topMargin = 10 - $(window).scrollTop();

    if (scroll >= 370) {
        $("#res-wrap").addClass("change-div-canvas");   // removed the . from class
        $("#res-wrap").css("margin-top", "90px"); ;     // change margin from top for close infoWindow button
    } else {
        $("#res-wrap").removeClass("change-div-canvas");  // removed the . from class
        $("#res-wrap").css("margin-top", topMargin+"px"); ;
    }
}); 

1 个答案:

答案 0 :(得分:1)

使用此CSS:

#res-wrap
{    
    margin-top: 90px;
    height: calc(100% - 75px);
    max-height: none;
}