Disable vertical scroll bar on div overflow: auto

后端 未结 8 1738
别跟我提以往
别跟我提以往 2020-12-23 08:48

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

相关标签:
8条回答
  • 2020-12-23 09:09

    Add the following:

    body{
    overflow-y:hidden;
    }
    
    0 讨论(0)
  • 2020-12-23 09:09

    How about a shorthand notation?

    {overflow: auto hidden;}
    
    0 讨论(0)
  • 2020-12-23 09:13

    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; }
    
    0 讨论(0)
  • 2020-12-23 09:21

    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>
    
    0 讨论(0)
  • 2020-12-23 09:25

    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)

    0 讨论(0)
  • 2020-12-23 09:28

    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.

    0 讨论(0)
提交回复
热议问题