HTML 容器未扩展到内部内容高度绝对定位

标签 html css

所以,

<div id="page-wrap">
  <div id="main-content>
    <div id="main-content-inner">
    </div>
  </div>
</div>

main-content 是相对定位,page-wrap 是默认定位,main-content-inner 是绝对定位。

问题是 page-wrap 高度没有扩展到 main-content-inner 的高度。 main-content-inner 显示得很好,但它显示在 page-wrap 的边界之外。因此,如果我将溢出设置为隐藏在页面包装上,我的主要内容内部就会被切断。如何使我的分页高度扩展到其子容器的最高高度?

#page-wrap {
width:100%;
min-height:100%;
height:auto;
height:100%;
margin-bottom:-20px;
overflow:hidden;

}

#main-content {
width: 100%;

margin-left: -295px;
position:relative;

}
#main-content-inner {
left: 560px;
border-radius:8px;
border-style:solid;
border-width:2px;
border-color:#53D8FF;
padding:20px;
padding-bottom:0;
background-color:#000000;
position:absolute;
top:100px;
min-width:60%;
max-width:60%;


}

最佳答案

如果您正在使用 min-height 属性,那么为什么要在它之后使用 height 属性。当您设置 height: 100% 时,我相信您将 #page-wrap 高度限制为正好 100%。尝试删除 height 定义,看看是否能解决问题。

关于HTML 容器未扩展到内部内容高度绝对定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7494759/

相关文章:

javascript - 防止转义文本节点上的特殊字符(JS-HTML)

HTML 删除特定边框

css - 如何在 Bootstrap 中的一组行的末尾添加一长列?

css - 演示中的 KendoUI Grid 外观和感觉不同

css - 当我的页面引用在 HTTPS 中时,为什么 Facebook 会在 HTTP 中为我的应用程序的 css 插入预加载脚本?

javascript - 使用 Vb.net 在 td 单元后端动态添加 css 类

html - 中间div和右div在里面的DIV

html - 摆脱复杂表中的空白区域

javascript - 关于分组和附加 div 的问题

javascript - 背景图像属性中的 GIF 图片需要停止动画