实现可调整大小的文本区域?
Stackoverflow 如何实现可调整大小的文本区域?
这是他们自己推出的东西,还是我可以轻松附加到我网站上的文本区域的公开组件?
我发现了这个问题,但它并没有完全达到我想要的效果。
这更多地讨论了自动调整文本区域的大小,而我想要一个可以向上拖动的小抓取区域向下。
How does Stackoverflow implement the resizable textarea?
Is that something they rolled themselves or is it a publicly available component that I can easily attach to textareas on my sites?
I found this question and it doesn't quite do what I want.
That talks more about automatically resizing textareas whereas I want the little grab-area that you can drag up and down.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我最近需要类似的功能。 它名为 Autogrow,它是令人惊叹的 jQuery 库
I needed a similar functionality recently. Its called Autogrow and it is a Plugin of the amazing jQuery library
起初我认为这是 Wysiwym Markdown 编辑器 的内置功能,但 Shog9 是正确的:它是根本没有内置,但是由 jQuery 插件 TextAreaResizer 提供(我被用来检查 编辑器演示,因为 Google Chrome 本身在文本区域上添加了可扩展功能 - 与 Safari 浏览器非常相似)。
At first I believed it was a built-in feature of the Wysiwym Markdown editor, but Shog9 is correct: it's not baked-in at all, but is courtesy of the jQuery plugin TextAreaResizer (I was lead astray by the browser was using to check on the editor demo because Google Chrome itself adds the expandable functionality on textareas—much like the Safari browser does).
StackOverflow 使用 jQuery 插件来完成此操作:TextAreaResizer。
验证这一点很容易 - 只需从站点中提取 JS 文件即可。
历史注释:最初编写此答案时,WMD 和 TextAreaResizer 是两个独立的插件,它们都不是由 SO 开发团队编写的(另请参阅:micahwittman 的回答)。 此外,该网站的 JavaScript 非常容易阅读...这些都不再是严格的真实情况,但 TextAreaResizer 仍然工作得很好。
StackOverflow uses a jQuery plugin to accomplish this: TextAreaResizer.
It's easy enough to verify this - just pull the JS files from the site.
Historical note: when this answer was originally written, WMD and TextAreaResizer were two separate plugins, neither one of which was authored by the SO Dev Team (see also: micahwittman's answer). Also, the JavaScript for the site was quite easy to read... None of these are strictly true anymore, but TextAreaResizer still works just fine.
现在可以使用仅 CSS 的解决方案
(至少需要 Chrome
v123
)使用(新)
field-sizing
属性:CSS-only solution is now possible
(requires Chrome
v123
minimum)Using the (new)
field-sizing
property:使用 AngularJS:
这将改变所有文本区域以增大/缩小。 如果您只想放大/缩小特定的文本区域 - 将顶部部分更改为如下所示:
希望有帮助!
Using AngularJS:
This will transform all your textareas to grow/shrink. If you want only specific textareas to grow/shrink - change the top part to read like this:
Hope that helps!
这个怎么样,它的工作
what about this, its work