18910140161

将div高度设置为浏览器剩余高度

顺晟科技

2021-09-01 12:02:15

75

我有一个div(容器),它定位于静态定位的父级。我的目标是使容器具有设置的浏览器的高度,更大高度~600px。它目前的开始位置是~中间的页面,我希望它扩展到底部的浏览器页面,并有高度动态变化,如果浏览器大小是更新。overflow-scroll-container也可能只包含3-4个选项,在这种情况下div height不应该扩展到浏览器的底部。

.parent {
    position: static;
}

.absolute-container {
    display: block;
    position: absolute;
    z-index: 121;
    background-color: #FFF;
    width: 90vw;
}

.overflow-scroll-container {
    overflow-y: scroll;
    padding: 4px 8px;
}

.content-footer {
    margin: 8px 0;
    display: -ms-flexbox;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #BECAD6;
}



<div class='parent'>
   <button>Example Dropdown</button>
   <div class='absolute-container'>
      <div class='overflow-scroll-container'>
        <button>Button 1</button>
        <button>Button 2</button>
        <button>Button 3</button>
        <button>Button 4</button>
        <button>Button 5</button>
        <button>Button 6</button>
        <button>Button 7</button>
        <button>Button 8</button>
      </div>
      <div class='content-footer'>
        <button>Reset</button>
        <button>Done</button>
      </div>
   </div>
</div>


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航