从未知高度创建可垂直滚动的div

时间:2016-10-20 09:10:33

标签: html css

我有一个高度为100%的弹出式div。

.popup{
height:100%;
}

我已经开始并创造了60%的利润率

.popup{
margin-top:60%;
}

因此弹出窗口底部只有40%空间可用。

40%底部空间,我希望有一个可滚动的div容器,其高度可能为500px。这不起作用,只有40%空格可用,并且不显示滚动条。

如何500px空间可用40%

3 个答案:

答案 0 :(得分:1)

检查此代码段:



body,
html,
.outer {
    width: 100%;
    height: 100%;
}
.wrapper-top, .wrapper-bottom {
    position: relative;
    width: 400px;
    top: 0;
    bottom: 0;
    border: 1px solid #555;
}
.wrapper-top {
    height: 60%;
}
.wrapper-bottom {
    height: 40%;
}
.inner {
    position: absolute;
    width: 100%;
    top: 0px;
    bottom: 0px;
    overflow-y: auto;
}

<div class="outer">
<div class="wrapper-top">
   <div class="inner">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
   </div>
</div>
<div class="wrapper-bottom">
   <div class="inner">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
   </div>
</div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

.main{
  width:100%;
  height:350px;
  border:1px solid;
}
.top{
  width:100%;
  height:60%;
  border:1px solid red;
}
.bottom{
  display:inline-block;
  width:100%;
  height:38%;
  border:1px solid #ff6600;
  padding:5px;
  overflow:auto;
}
.content{
  width:100%;
  height:500px;
  border:1px solid blue;
}
<div class="main">
<div class="top"></div>
  <div class="bottom">
  <div class="content"></div>
  </div>
</div>

答案 2 :(得分:0)

请检查这个小提琴:https://jsfiddle.net/vadimb/wx2v7pj6/

.popup {  
    margin-top: 60%;
    background-color: red;
    height: 250px;
    overflow: hidden;
}

.inner {
   overflow-y: scroll;
   height: 250px;
}

和html

<div class="popup">
 <div class="inner">
 abcd<br/>....
 </div>
</div>