Add a scrollbar to a <textarea> [duplicate]

拜拜、爱过 提交于 2019-12-06 18:31:52

问题


I would like to add a scrollbar to a textarea, so that it always appears, even when there is nothing to scroll down to. If there is nothing for it to scroll down to, I would prefer if it could be greyed out, indicating that there is nothing below.

How would I do this?


回答1:


What you need is overflow-y: scroll;

Demo

textarea {
    overflow-y: scroll;
    height: 100px;
    resize: none; /* Remove this if you want the user to resize the textarea */
}



回答2:


Try adding below CSS

textarea
{
    overflow-y:scroll;
}



回答3:


You will need to give your textarea a set height and then set overflow-y

textarea
{
resize: none;
overflow-y: scroll;
height:300px;
}



回答4:


textarea {
    overflow-y: scroll; /* Vertical scrollbar */
    overflow: scroll; /* Horizontal and vertical scrollbar*/
}



回答5:


like this

css

textarea {

overflow:scroll;
height:100px;
}



回答6:


HTML:

<textarea rows="10" cols="20" id="text"></textarea>

CSS:

#text
{
    overflow-y:scroll;
}


来源:https://stackoverflow.com/questions/19420923/add-a-scrollbar-to-a-textarea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!