Disable vertical scroll bar on div overflow: auto

HtmlCssScrollScrollbar

Html Problem Overview


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

Html Solutions


Solution 1 - Html

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

overflow-y: hidden; // hide vertical
overflow-x: hidden; // hide horizontal

Solution 2 - Html

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.

Solution 3 - Html

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>

Solution 4 - Html

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.

Solution 5 - Html

How about a shorthand notation?

{overflow: auto hidden;}

Solution 6 - Html

Add the following:

body{
overflow-y:hidden;
}

Solution 7 - Html

This rules are compatible whit all browser:

body {overflow: hidden; }
body::-webkit-scrollbar { width: 0 !important; }
body { overflow: -moz-scrollbars-none; }
body { -ms-overflow-style: none; }

Solution 8 - Html

if you want to disable the scrollbar, but still able to scroll the content of inner DIV, use below code in css,

.divHideScroll::-webkit-scrollbar {
    width: 0 !important
}
.divHideScroll {
    overflow: -moz-scrollbars-none;
}
.divHideScroll {
    -ms-overflow-style: none;
}

divHideScroll is the class name of the target div.

It will work in all major browser (Chrome, Safari, Mozilla, Opera, and IE)

Solution 9 - Html

I used this code

html, body
    {
      -ms-content-zooming:none;  
      touch-action: none;
      content-zooming: none;
      overflow-y: hidden; // hide vertical
    overflow-x: hidden; 
    overflow-y: none; // hide vertical
    overflow-x: none; 
    }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoedborgView Question on Stackoverflow
Solution 1 - HtmlLukeView Answer on Stackoverflow
Solution 2 - HtmlSiva CharanView Answer on Stackoverflow
Solution 3 - HtmlRandom GuyView Answer on Stackoverflow
Solution 4 - HtmlNirav MehtaView Answer on Stackoverflow
Solution 5 - HtmlChong Lip PhangView Answer on Stackoverflow
Solution 6 - HtmlZeinabView Answer on Stackoverflow
Solution 7 - HtmltamuekaView Answer on Stackoverflow
Solution 8 - HtmlTahir AlviView Answer on Stackoverflow
Solution 9 - Htmluser3806549View Answer on Stackoverflow