2017-10-10 106 views
-5

我有两个div的第一个可更换没有滚动(红色)和第二个div(黑色)高度应该改变为填充屏幕的最大尺寸(第二个一个有滚动)。任何想法如何做到这一点?我不想让红色的卷轴。我想使一个div响应窗口和第二个div的高度

添加代码已经我想什么:

$(document).ready(function() { 
      var h = $("#topContainer").height(); 
      var heightBottomContent = $(window).height() - h; 
      $("#botContainer").height(heightBottomContent); 
     }); 

enter image description here

+1

请告诉我们你已经尝试过自己 –

+0

请添加代码 – Tim

+0

''我想让div响应第二个div的窗口和高度“'我想去太空......两者似乎都是可能的,但真正的问题是我们到目前为止尝试过什么...... –

回答

0

我想你已经解决了自己的问题,就必须实现它在窗口load & resize事件:

$(window).on('load',fix_height).on('resize',fix_height); 

function fix_height() { 
    var h = $("#topContainer").height(); 
    var heightBottomContent = $(window).height() - h; 
    $("#botContainer").height(heightBottomContent); 
} 
+0

'.on('resize')'did not work .. – Adriano

相关问题