问题
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