具有溢出隐藏但没有滚动条的可滚动区域 [英] A scrollable area with the overflow hidden but no scroll bar

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

问题描述

有一种方法有溢出div隐藏溢出,没有滚动条,但仍然可滚动(通过鼠标滚轮/触摸输入)?

Is there a way of having an overflowing div that hides the overflow, doesn't have a scroll bar but is still scrollable (by means of the mouse wheel / touch input)?

例如

<!DOCTYPE html>  
    <div id="longtext" style="width:100px; height:100px;">  
        Lorem ipsum....  
    </div>

我的CSS尝试失败,因为 overflow:hidden; 停止可滚动区域,而 overflow:auto / overflow:scroll 有滚动条。

My CSS attempts have failed as overflow: hidden; stops the area being scrollable whilst overflow: auto/overflow: scroll has the scrollbars.

提前感谢

推荐答案

浏览器的内容是可滚动的,但同时试图告诉它不行为,如果它是可滚动的。我不确定这是一个明智的想法。

What you're doing is telling the browser that the content is scrollable, but at the same time trying to tell it to not behave as if it is scrollable. I'm not sure this is a sensible idea.

我可以找到的最接近的想法是一个依赖于IE的方法,用您自己的颜色方案设置滚动条: p>

The closest idea I could find is an IE-dependent approach, styling the scrollbars with your own colour scheme:



#div {
margin: 0 0 0 0;
padding: 0 0 0 0;
scrollbar-face-color: #666666;
scrollbar-highlight-color: #333333;
scrollbar-shadow-color: #222222;
scrollbar-3dlight-color: #888888;
scrollbar-arrow-color: #ff0000;
scrollbar-track-color: #222222;
scrollbar-darkshadow-color: #111111
}

如果您要更改颜色以匹配你的div的背景,这可能是一个想法。但是,请注意,这是一个仅限IE的行为。

If you were to change the colours to match your div's background, that might be an idea. However, it's important to note that it is an IE-only behaviour.

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

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