小编Sam*_*iza的帖子

CSS div高度自动为0

由于某种原因,我的固定标题高度为 0。如何使标题 div 采用其子元素 header-title 的高度?我试图在动态分辨率方面显示固定标题下方的内容。网上的解决方案是针对包含浮动元素的div;但这不是这里发生的事情。代码笔: http: //codepen.io/samaraiza/pen/czajq

HTML:
<div class="container">
  <div class="header">
    <div class="header-title"> Cool Title </div>
  </div>
  <div class="content"> Cool Content </div>
</div>

CSS:
.container {
  position: absolute;
  width: 100%;
  height: 100%;
  background: green;
}

.header {
  position: relative;
  width: 100%;
  height: auto;
  background: yellow;
  text-align: center;
  font-size: 3vw;
}

.header-title {
  position: fixed;
  width: 100%;
  background: red;
}

.content {
  position: relative;
  font-size: 1.5vw;
}
Run Code Online (Sandbox Code Playgroud)

感谢大家!

css height zero

5
推荐指数
1
解决办法
5290
查看次数

标签 统计

css ×1

height ×1

zero ×1