html - 设置为相对时父容器不采用内容高度

标签 html css

<分区>

我有,

HTML,

<div class="outer">
    <div class="inner"></div>    
</div>

CSS,

.outer {
    position: relative;
    overflow: scroll;    
    border : 1px solid red;
    height: auto;
}
.inner {
    position: absolute;
    width: 1200px;
    height: 895px;
    top: 0px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    border : 1px solid yellow;
}

问题:- 外部不占据内部内容的完整高度

预期 : - 它应该占据完整的高度

注意事项

我不能硬编码外部高度

我想要一个外层的滚动条。

http://jsfiddle.net/sefkao23/

最佳答案

你好,现在尝试这种方式

您只需将您的 .outer class widthheight 定义为这个

.outer {
    position: relative;
       height: 895px; 
    border : 1px solid red;
    width: 1200px;
}
.inner {
    position: absolute;
    
   
    top: 0px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    border : 1px solid yellow;
}
<div class="outer">
    <div class="inner"></div>    
</div>

关于html - 设置为相对时父容器不采用内容高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32608482/

上一篇:html - 为什么不看看上面有没有爬上右栏

下一篇:javascript - 在砌体 View 中增加顶部位置

相关文章:

javascript - 如何添加树状图文本的链接?

html css 粘性等

css - 如何在 FontAwesome 字形上叠加数字?

javascript - 使用 JQuery 将具有 x 和 y 坐标的图标定位在另一个图像的顶部

javascript - 我如何淡化背景图像

javascript - 更改 html 中链接点击的占位符

javascript - 当用户滚动文档 jquery 时停止光标在光标 div 上更改

jquery - 过滤不区分大小写的 div 标签

css - HTML5 CSS 3 flex 盒

css - 所有浏览器都允许我用 rgba 替换颜色 # 吗?