将父div展开为子高

编程入门 行业动态 更新时间:2024-10-28 04:22:05
本文介绍了将父div展开为子高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个类似这样的页面结构:

< 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展开为子高

本文发布于:2023-10-08 04:38:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471533.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!