【问题标题】:How can I make my element take the full screen and disable the scrolling?如何让我的元素占据全屏并禁用滚动?
【发布时间】:2021-09-09 21:07:45
【问题描述】:

我想让我的孩子 div 占据屏幕的剩余空间并禁用滚动选项,因为我使用的是 PanZoom,我希望孩子的 div 始终为 100& 屏幕

<div class="parent">
    <menu> ... </menu>
    <div class="children"> ​
        <panzoom></panzoom> //the image can change size, height etc.
    </div>
</div>

我尝试使用

children  {
    height : 100%
}

但使用 PanZoom,div 更大,滚动选项出现。

【问题讨论】:

    标签: javascript html css vue.js


    【解决方案1】:

    老实说,我不确定你的意思,你的问题有点不清楚,但是,这里有一个可能的答案。

    如果你想让一个元素真正全屏,你不应该只是将高度设置为 100%,你需要考虑用户的屏幕,像这样:

    .element {
       height: 100vh;     // sets the height to the full screen view height
       width: 100vw;      // sets the width to the full screen view width
       overflow: hidden;  // hides scrolling
    }
    

    【讨论】:

    • 是的!对不起......我试图做的。但是,我的元素现在还有另一个问题。我的元素占据了 110% 的屏幕。因为我使用的是 Vuetify 并且我在一个 里面,所以它只需要视图的整个高度而不是屏幕的高度。我可以这样做:高度:100vh - menu.height 吗?
    【解决方案2】:

    如果你不想滚动条出现,你可以这样做

    .children {
        overflow: hidden;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-11
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 2017-11-30
      相关资源
      最近更新 更多