[英]div height for an inner div
I'm appending a div
inside another div
like this: 我追加
div
另一个里面div
像这样:
$('#maindivid').append('<div id="newid" style="background: url(xyz/image/test.png); position:absolute; min-height:100%; width:100%; height:100%; top:0px; left:0px; overflow:auto;"></div>');
But my new div
doesn't get the entire height of the container div
. 但是我的新
div
无法获得容器div
的整个高度。 How can this be achieved? 如何做到这一点?
将新div的属性设置为height:inherit
;
尝试设置父级div的高度,然后将子级的高度设置为100%。
Parent Div: 家长Div:
<div id="maindivid" scrollleft="0" scrolltop="0" style="border:1px solid black; width: auto; height: 561.4px;" class="class-new " >
Parent Border
</div>
script to append the child: 追加孩子的脚本:
$('#maindivid').append('<div id="childid" style="border: 1px solid red; position:absolute; width:100%; height:inherit; ">Child</div>');
this works on jsfiddle.net: http://jsfiddle.net/qY47q/ 这个工程上jsfiddle.net: http://jsfiddle.net/qY47q/
Note: I did remove the height:100% on the child because you've already specify that the height will be inherit to the parent. 注意:我确实删除了子级的height:100%,因为您已经指定了高度将继承给父级。 Also, I added border so that I could see the actual height of the div
另外,我添加了边框,以便可以看到div的实际高度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.