Disable vertical scroll bar on div overflow: auto

2019-01-31 05:10发布

Is it possible to allow only a horizontal scroll bar when using overflow:auto (or scroll)?

5条回答
放我归山
2楼-- · 2019-01-31 05:39

You should use only

overflow-y:hidden; - Use this for hiding the Vertical scroll

overflow-x:auto; - Use this to show Horizontal scroll

Luke has mentioned as both hidden. so I have given this separately.

查看更多
看我几分像从前
3楼-- · 2019-01-31 05:40

These two CSS properties can be used to hide the scrollbars:

overflow-y: hidden; // hide vertical
overflow-x: hidden; // hide horizontal
查看更多
Luminary・发光体
4楼-- · 2019-01-31 05:42

overflow: auto;
overflow-y: hidden;

For IE8: -ms-overflow-y: hidden;

Or Else :

To hide X:

<div style="height:150x; width:450px; overflow-x:hidden; overflow-y: scroll; padding-bottom:10px;"></div>

To hide Y:

<div style="height:150px; width:450px; overflow-x:scroll ; overflow-y: hidden; padding-bottom:10px;"></div>
查看更多
Rolldiameter
5楼-- · 2019-01-31 05:42

If you want to accomplish the same in Gecko (NS6+, Mozilla, etc) and IE4+ simultaneously, I believe this should do the trick:V

body {
overflow: -moz-scrollbars-vertical;
overflow-x: hidden;
overflow-y: auto;
}

This will be applied to entire body tag, please update it to your relevant css and apply this properties.

查看更多
小情绪 Triste *
6楼-- · 2019-01-31 05:44

Add the following:

body{
overflow-y:hidden;
}
查看更多
登录 后发表回答