1
A
回答
1
在两者上设置位置。
#ParentDiv {
position:relative;
height:auto;
}
#ChildDiv {
position:absolute;
/* top/left/right force it to dimensions of parent, if needed */
top:0;
left:0;
right:0;
height:100%;
}
父母会伸展以适应孩子。
1
#ParentDiv {
position:relative;
height:auto;
}
#ChildDiv {
position:absolute;
/* top/left/right force it to dimensions of parent, if needed */
top:0;
left:0;
right:0;
height:100%;
}
您的ParentDiv高度为AUTO,因此孩子强制Parent DIV扩展至浏览器高度的100%。从Parenet DIV中删除auto。你的问题将被解决。
相关问题
- 1. 儿童度100%的高度
- 2. CSS Parent Div高度:自动,儿童高度100%,但高度为0px
- 3. Flexbox拉伸div高度以填充父div的剩余高度
- 4. DIV宽度不扩展,以适应儿童DIV的宽度 - IE7
- 5. 父母的DIV高度100%
- 6. Bootstrap儿童元素高度100%
- 7. 儿童元素不能拉伸固定高度的父容器
- 8. 更改父div高度取决于使用javascript的儿童绝对div高度
- 9. 儿童DIV动态高度和绝对位置 - 给予高度父DIV
- 10. CSS div高度不伸展
- 11. 高度的div不延伸至100%
- 12. 灵活高度和宽度的Flexbox儿童:100%
- 13. '伸展'的div内的背景图像 - 100%的高度
- 14. 伸展高度DIV在固定高度的另一个DIV下
- 15. 使父级div宽度不扩展到适合儿童divs
- 16. 如何将div伸展至100%的页面高度?
- 17. 背景图像伸展100%的高度Div
- 18. 制作DIV 100%拉伸另一DIV 100%的高度内
- 19. Div 100%高度
- 20. 100%div高度
- 21. 100%高度div
- 22. JPanel与儿童匹配的父宽度和包装的高度
- 23. css让父母的div 100%身高和儿童可滚动
- 24. ExpandableListView动态儿童高度
- 25. 容器高度w.r.t儿童
- 26. 以css中父级的高度为中心儿童
- 27. Div高度没有完全伸展到100%
- 28. div的高度100%
- 29. 父格扩展到儿童的div
- 30. 身高儿童的div匹配父
如果你想父母的div是100%,为什么不把它指定为100%? – Mooseman
这是默认行为。您甚至不需要将高度设置为100%。或者我误解了这个问题。请详细说明...... – Pevara
在问题中加入你的html/css。 –