允许滚动,但隐藏滚动条 [英] Allow scroll but hide scrollbar

查看:113
本文介绍了允许滚动,但隐藏滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 div 具有这样的元素样式:

I have a div with element styles like this:

 <div style="overflow-y: auto; max-height: 300px;">< id="DivTableContainer" ></div>

当它变得高于300px时,我需要允许沿y轴滚动,但我需要设置visiblity = false滚动条本身。

I need to allow scrolling along the y-axis when it becomes higher than 300px, this works fine. But I need to set "visiblity = false" to scroll bar itself.

我试图使用此元素样式:

I tried to use this element style:

overflow-y: hidden;

当它隐藏滚动条时,它也不允许滚动。是否有一种方法可以滚动而不让滚动条可见?

While it hides the scroll bar, it also disallows scrolling. Is there a way to get scrolling without having the scrollbar visible?

推荐答案

如果你在HTML中使用两个div容器,更好。

It's better, if you use two div containers in HTML .

如下所示:

HTML:

<div id="container1">
    <div id="container2">
        // Content here
    </div>
</div>

CSS:

 #container1{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

 #container2{
    height: 100%;
    width: 100%;
    overflow: auto;
    padding-right: 20px;
}

这篇关于允许滚动,但隐藏滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆