2016-11-04 86 views
2

这个问题可能以前已经问过,但是我找不到可以帮助我的问题。反正,我创建了一个文本框,下面的脚本:如何使文本框滚动垂直溢出CSS的HTML?

CSS:

.cln{ 
 
top:220px; 
 
width:680px; 
 
height:350px; 
 
text-align:left; 
 
overflow:scroll; 
 
white-space: nowrap; 
 
overflow:hidden; 
 
text-overflow:ellipsis; 
 
}
<input type="text" class="cln" placeholder="That is my pet right there:)" maxlength="2024"/>

的问题是,在文本框中键入距离市中心50% to 50%开始,从来没有滚动到垂直滚动,就像你输入的行一样。 但我希望它从左上角开始,并且永远不会跨越文本框边框。 到目前为止,我所能做的只是改变,删除white-space overflow text-align等等,但没有任何帮助。

感谢提前:)

+4

你应该使用'textarea'。 –

+0

尝试添加textarea – weinde

回答

2

使用textarea像下面。它会自动滚动

This will scroll automatically...<br/> 
 
<textarea type="text" class="cln" placeholder="That is my pet right there:)" col=30 rows=10> </textarea>

+0

行仍然没有滚动垂直,仍然水平 – John

+0

@John,再次检查它 – Abk

+0

O.k只是想通了,不得不删除'在我的CSS空白',反正谢谢 – John

0

使用textarea的不输入

<textarea class="cln" placeholder="That is my pet right there:)" /> 
0

你能使用textarea的,而不是输入?

<textarea type="text" class="cln" placeholder="That is my pet right there:)" maxlength="2024"/></textarea> 

Example