如何制作垂直滚动的文本区域?
How to make vertically scrollable text area?
我有一个 textarea
html 元素,它可能包含 URL。用户应该能够点击这些 URL 来打开它们。目前代码如下所示:
<textarea rows="26" class="form-control" disabled> {{ text|urlize }}</textarea>
当然,目前不支持链接。看起来 textarea
应该用其他东西代替。我尝试使用 div
代替,但我不确定如何限制它的高度(对于 textarea
我使用 rows="26"
)并使其可滚动。
请检查此代码
html
<div class="textarea"> </div>
CSS
.textarea{
width:50%;
background-color:#eee;
overflow:hidden;
height:250px;
max-height:250px;
border:1px solid #ccc;
overflow-y: auto;
}
我有一个 textarea
html 元素,它可能包含 URL。用户应该能够点击这些 URL 来打开它们。目前代码如下所示:
<textarea rows="26" class="form-control" disabled> {{ text|urlize }}</textarea>
当然,目前不支持链接。看起来 textarea
应该用其他东西代替。我尝试使用 div
代替,但我不确定如何限制它的高度(对于 textarea
我使用 rows="26"
)并使其可滚动。
请检查此代码
html
<div class="textarea"> </div>
CSS
.textarea{
width:50%;
background-color:#eee;
overflow:hidden;
height:250px;
max-height:250px;
border:1px solid #ccc;
overflow-y: auto;
}