在可滚动div上方添加div会推动页面高度下方的滚动条

时间:2013-09-27 12:21:19

标签: html css

我无法在可滚动div上方添加任何HTML元素,而不会将该div从页面底部推出。这显然是一个100%的高度问题,但不确定如何解决。

http://codepen.io/establish/pen/lCGwn

HTML

<div class="container">

  <div class="stream page">
    <div>THIS IS A DIV</div>
    <div>THIS IS ANOTHER DIV</div>
    <div class="stream-content">
      <h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut odio libero, posuere in tortor quis, malesuada ullamcorper ante. Morbi sed orci nisi.</h2>

      <h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut odio libero, posuere in tortor quis, malesuada ullamcorper ante. Morbi sed orci nisi.</h2>

      <h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut odio libero, posuere in tortor quis, malesuada ullamcorper ante. Morbi sed orci nisi.</h2>
    </div>
  </div>

  <div class="detail page">
  </div>

</div>

CSS

.container {
  background-color: pink;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0; 
}

.detail {
  background-color: blue;
  left: 425px;
}

.stream {
  background-color: green;
  width: 425px;
}

.stream-content { 
  overflow-y: scroll;
   height: 100%;
}

0 个答案:

没有答案