将父div展开为子高 [英] Expand Parent Div To Child Height
问题描述
我有一个类似这样的页面结构:
< body&
< div id =parent>
< div id =childRightCol>
/ * Content * /
< / div>
< div id =childLeftCol>
/ * Content * /
< / div>
< / div>
< / body>
我想为父 div
当内部 div
高度
展开时,在 height
/ p>
编辑:
一个问题是如果 width
的子内容扩展到浏览器窗口的 width
之后,我当前的CSS将一个水平滚动条放在父 div
。我想滚动条在页面级别。目前我的父div设置为 overflow:auto;
你能帮我使用CSS吗?
尝试这样做的父母,它为我工作。
overflow:auto;
更新:
还有一个解决方案:
父:
display:table;
子:
display:table-row;
I have a page structure similar to this:
<body>
<div id="parent">
<div id="childRightCol">
/*Content*/
</div>
<div id="childLeftCol">
/*Content*/
</div>
</div>
</body>
I would like for the parent div
to expand in height
when the inner div
height
expands.
Edit:
One problem is that if the width
of the child content expands past the width
of the browser window, my current CSS puts a horizontal scrollbar on the parent div
. I would like the scrollbar to be at the page level. Currently my parent div is set to overflow: auto;
Can you please help me with the CSS for this?
Try this for the parent, it worked for me.
overflow:auto;
UPDATE:
One more solution that worked:
Parent:
display: table;
Child:
display: table-row;
这篇关于将父div展开为子高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!