html - 绝对定位的 div 高度不扩展

标签 html css

我不确定为什么绝对位置 div 的高度没有扩展( div.class1 )

fiddle :http://jsfiddle.net/z9Unk/209/

HTML

<div class="container">
  <div class="content">
    <div class="space">
    </div>
    <div class="class1 hz">
      <div class="class2 class3">
        item2
      </div>
      <div class="class2 class3">
        item2
      </div>
    </div>
  </div>
</div>

CSS

.container {
  position:relative;
  height: 100%;
  width:100%;
}
.space {
  margin-top:80px;
}

.content {
  height:100%;
  border:1px solid transparent;
}

.hz {
  top:20%;
  margin:0 auto;
  left:0px;
  right:0px;
  display:inline-block;
}


.class1 {
  position: absolute;
  top:160px;
  width: 985px;
  height:100%;
  border:1px solid blue;
}

.class2 {
  width : 275px;
  height : 250px;
  margin-right:20px;
   border:1px solid red;
}

.class3 {
  width : 325px;
  height: 280px;
  margin-right:3px;
  display:inline-block;
}

请帮我解决这个问题。

最佳答案

display:table; 添加到 .class1

.class1 {
  position: absolute;
  display:table;
  top:160px;
  width: 985px;
  height:100%;
  border:1px solid blue;
}

更新的 fiddle :http://jsfiddle.net/z9Unk/213/

关于html - 绝对定位的 div 高度不扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18233870/

相关文章:

html - 文本没有包裹在均匀分布、宽度均匀的 flexbox 中

javascript - 在其他两个方法完成后调用一个方法

css - 当单元格内容非常小时,表格单元格垂直对齐的奇怪行为

css - Fontawesome 4.3安装

html - Vuetify - 对齐 div、行和按钮的中心

javascript - jQuery 从 html 和正文选择器中排除 div

html - Font awesome 在 Squarespace 中敲打其他 div/代码块

javascript - 登录认证后提交表单

javascript - 通过 HTML 代码中的搜索和替换填写协议(protocol)相关 URL

HTML 日期选择器与日期输入重叠