HTML: How to create a DIV with only vertical scroll-bars for long paragraphs?

浪子不回头ぞ 提交于 2019-11-28 03:37:23
janmoesen

Use overflow-y. This property is CSS 3.

to hide the horizontal scrollbars, you can set overflow-x to hidden, like this:

overflow-x: hidden;
Daniel Vassallo

You need to specify the width and height in px:

width: 10px; height: 10px;

In addition, you can use overflow: auto; to prevent the horizontal scrollbar from showing.

Therefore, you may want to try the following:

<div style="width:100px; height:100px; overflow: auto;" >
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
  text text text text text text text text text
</div>
raji

Thank you first

Use overflow:auto it works for me.

horizontal scroll bar disappears.

For any case set overflow-x to hidden and I prefer to set max-height in order to limit the expansion of the height of the div. Your code should looks like this:

overflow-y: scroll;
overflow-x: hidden;
max-height: 450px;

To show vertical scroll bar in your div you need to add

height: 100px;   
overflow-y : scroll;

or

height: 100px; 
overflow-y : auto;
Amobi Chuks
overflow-y : scroll;
overflow-x : hidden;

height is optional

You can use the overflow property

style="overflow: scroll ;max-height: 250px; width: 50%;"
hemant

I also faced the same issue...try to do this...this worked for me

        .scrollBbar 
        {
        position:fixed;
        top:50px;
        bottom:0;
        left:0;
        width:200px;
        overflow-x:hidden;
        overflow-y:auto;
       }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!