Hide html horizontal but not vertical scrollbar

后端 未结 8 1847
南笙
南笙 2020-11-28 19:49

I have an HTML textarea that is of fixed width, but variable height. I would like to set overflow:scroll and be able to show a vertical scrollbar, but not a hor

相关标签:
8条回答
  • 2020-11-28 19:58

    You can use css like this:

    overflow-y: scroll;
    overflow-x: hidden;
    
    0 讨论(0)
  • 2020-11-28 19:58
    .combobox_selector ul {
        padding: 0;
        margin: 0;
        list-style: none;
        border:1px solid #CCC;
        height: 200px;
        overflow: auto;
        overflow-x: hidden;
    }
    

    sets 200px scrolldown size, overflow-x hides any horizontal scrollbar.

    0 讨论(0)
  • 2020-11-28 19:59
    <div style="width:100px;height:100px;overflow-x:hidden;overflow-y:auto;background-color:#000000">
    
    0 讨论(0)
  • 2020-11-28 20:00

    Disable horizontal scrollbar completely by adding this code.

    body{
      overflow-x: hidden;
      overflow-y: scroll;
    }
    
    0 讨论(0)
  • 2020-11-28 20:01

    Using wrap=virtual in your HTML form boxes gets rid of the horizontal scrollbar at the bottom of the box:

      <textarea name= "enquiry" rows="4" cols="30" wrap="virtual"></textarea>
    

    See example here : http://jsbin.com/opube3/2 (Tested on FF and IE)

    0 讨论(0)
  • 2020-11-28 20:02
    selector{
     overflow-y: scroll;
     overflow-x: hidden;
    }
    

    Working example with snippet and jsfiddle link https://jsfiddle.net/sx8u82xp/3/

    .container{
      height:100vh;
      overflow-y:scroll;
      overflow-x: hidden;
      background:yellow;
    }
    <div class="container">
    
    <p>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    
    Why do we use it?
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    </p>
    
    <p>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    
    Why do we use it?
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    </p>
    
    <p>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    
    Why do we use it?
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    </p>
    
    <p>
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    
    Why do we use it?
    It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
    </p>
    
    </div>

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