If I have two divs, the parent of which (let's call it #parent) is dynamic in height, is there any way to keep a child div (let's call it #child) at the same height using jQuery, and for that height to increase and decease as the parent div responsively changes height?
问问题
11507 次
3 回答
10
尝试...
var h = $("#parent").height();
$("#child").height(h);
或者
$("#child").height($("#parent").height()); //to save a line of code
在更改 div 高度之后立即添加代码。无论是开启$(document).ready()
还是自定义功能
于 2013-11-08T19:45:06.230 回答
0
你也可以通过 CSS 来实现,只需将子 div 高度设置为 100%
#parent
{
//css of parent div
}
#child{
height:100%;
}
于 2013-11-08T19:49:11.797 回答
0
display: inline-block 对我有用。我在另一个 ng-repeat 中有一个嵌套的 ng-repeat,父母的身高总是 0
于 2016-09-09T08:13:12.937 回答