展开父级< div>达到孩子的身高 [英] Expanding a parent <div> to the height of its children
问题描述
我有一个类似于此的页面结构:
< body>
< div id =parent>
< div id =childRightCol>
/ *内容* /
< / div>
< div id =childLeftCol>
/ *内容* /
< / div>
< / div>
< / body>
我想要父母 div
来当内部 div
的高度
增加时,展开高度
。
编辑:
一个问题是,如果宽度$ c $子内容的c>展开超过了浏览器窗口的
宽度
,我当前的CSS将水平滚动条放在父元素 div
。我希望滚动条处于页面级别。目前我的父div被设置为 overflow:auto;
你能帮我用CSS吗?
溢出:汽车;
更新:
另外还有一个解决方案:
家长:
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
's height
increases.
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屋!