开发者

FF not auto scrolling textarea

I have a textarea that, when you fill a couple lines and still continue typing, does not automatically scroll down so you can see what you are typing. This is only a Firefox issue. Here is the CSS and textarea HTML:

#msg {
  width: 380px;
  resize: none;
  margin-top: 10px;
  margin-bottom: 5px;
  border: 1px solid;
  border-color: #000;
  overflow: hidden;
  padding: 6px;
}

<textarea id="msg" rows=2></textarea>

"overflow:hidden" is there because I don't want a scrollbar.开发者_JAVA百科 Adding "cols" to the textarea makes no difference.

Thanks for your help!


I can think of one workaround for this, and it is just an idea yet.

On the onkeydown event of the textarea, if you do element.scrollTop=element.scrollHeight, it will always scroll to the bottom of the textarea. You have to find a way to scroll to the caret position instead of the bottom (in case they are editing text not in the bottom), and you're done.


overflow: hidden is probably the source of your problems, take it out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜