如何隐藏textarea滚动条而不使用overflow:hidden? [英] How can I hide a textarea scrollbar without using overflow:hidden?

查看:428
本文介绍了如何隐藏textarea滚动条而不使用overflow:hidden?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在保持滚动行为的同时显示没有滚动条的textarea。由于用户类型,我只希望上面的行消失在文本框的顶部。

I want to display a textarea without a scrollbar while maintaining the scrolling behaviour. As the user types I just want the upper lines to disappear off the top of the text box.

我可以在IE和Chrome中使用overflow:hidden来实现此目的。但是,在Windows 5上测试Firefox 5时,textarea不会自动滚动,新文本会从textarea的底部而不是顶部。

I can achieve this in IE and Chrome using overflow:hidden. However, when testing in Firefox 5 on Windows the textarea doesn't automatically scroll and the new text drops off the bottom of the textarea instead of the top.

使用overflow:滚动效果很好,但我需要一种可靠的跨浏览器方式来隐藏滚动条。任何想法都将得到很大的赞赏。

Using overflow:scroll works well but I need a reliable cross-browser way to hide the scrollbar. Any ideas would be much appreciated.

推荐答案

使用jQuery应该是一种明智的方式:

Using jQuery should be a wise way:

$('textarea').keyup(function(){
    $(this).scrollTop(9999)
})

这篇关于如何隐藏textarea滚动条而不使用overflow:hidden?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆