使用溢出隐藏滚动条:滚动已启用 [英] Hide scrollbar with overflow:scroll enabled

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

问题描述

我需要隐藏滚动条上有一个div溢出:scroll;启用,以便div将使用鼠标和键盘滚动,但滚动条本身不会显示。

I need to hide the scrollbar on a div that has overflow:scroll; enabled so that the div will scroll with mouse and keyboard but the scrollbar itself will not be displayed.

有一种方法这样做与css或是javascript的方式go?

is there a way of doing this with css or is javascript the way to go?

推荐答案

你可以把滚动div放在第二个div里面,

You could put the scrolling div inside of a second div with overflow hidden, then just make the inner div a little wider and taller (the amount may vary depending on the browser, however).

这样的东西:

#outer {
    overflow:hidden;
    width:200px; 
    height:400px;
    border:1px solid #ccc;
}
#inner {
    overflow:scroll; 
    width:217px; 
    height:417px;
}​

http://jsfiddle.net/uB6Dg/1/

编辑:
不幸的是,您仍然可以通过突出显示文本和拖动到滚动条,多一点痛苦,但除此之外我认为javascript是走的路。

Unfortunately you can still get to the scrollbars by highlighting the text and dragging, and it does make padding etc a bit more of a pain, but other than this I think javascript is the way to go.

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

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