将滚动条添加到[重复]

问题描述 投票:15回答:6

我想将滚动条添加到文本区域,以使其始终显示,即使没有向下滚动的内容。如果没有向下滚动的内容,我希望它可以显示为灰色,表示下面没有任何内容。

我将如何做?

html css scroll textarea
6个回答
30
投票

您需要的是overflow-y: scroll;

Demo

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

6
投票

尝试在CSS下添加

textarea
{
    overflow-y:scroll;
}

5
投票

您将需要给文本区域设置一个高度,然后设置溢出-y

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

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

1
投票

喜欢这样

css

textarea {

overflow:scroll;
height:100px;
}

1
投票

HTML:

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

CSS:

#text
{
    overflow-y:scroll;
}
© www.soinside.com 2019 - 2024. All rights reserved.