简体   繁体   English

CSS:调整浏览器大小(变窄)时,垂直滚动条消失

[英]CSS: vertical scrollbar disappears when browser is resized (narrowed)

What causes this to happen? 是什么原因导致这种情况发生? I would expect the vertical scrollbar to appear no matter how narrow the browser window is. 无论浏览器窗口多么狭窄,我都希望垂直滚动条会出现。 The content in the grid is dynamic, but this issue seems to have nothing to do with the no of rows in the grid. 网格中的内容是动态的,但是此问题似乎与网格中的行数无关。 The scrollbar appears when the browser window is a certain size and remains as the window is widened, but disappears when the window is narrowed. 滚动条在浏览器窗口达到特定大小时出现,并在窗口扩大时保持不变,而在窗口缩小时消失。 The height is dynamic and set by the element as a style attribute via JavaScript. 高度是动态的,由元素通过JavaScript将其设置为样式属性。

<div id="mycontainer" class="mydiv" style="height: 142px;"></div>
<style>
    .mydiv {    
        background-color: white;     
        border-color: #d8d8d8;    
        border-style: solid;    
        border-width: 0 1px 1px;    
        height: 100%;
        width: 100%    
        margin: 0;    
        overflow-y: auto;    
        padding: 0;    
        position: relative;    
    }
</style>

嗯,情况是您正在使用溢溢-y,这将阻止div显示滚动条,并且事实是div内没有内容,也许您可​​以与div和内容共享plnkr?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM