简体   繁体   English

时调出滚动条<textareaautosize>缩小了</textareaautosize>

[英]Bring up scrollbar when <TextareaAutosize> is shrunk

I am using a <TextareaAutosize> component from the Material UI Library in my React app, as such:我在我的 React 应用程序中使用Material UI库中的<TextareaAutosize>组件,如下所示:

<TextareaAutosize 
   minRows="2"
   style={{resize: "vertical"}}
/>

This creates a textarea that autosizes based on the size of the content.这将创建一个基于内容大小自动调整大小的文本区域。 I have styled it so that the user is only able to manually expand vertically.我已经对其进行了样式设置,以便用户只能手动垂直扩展。

The current behavior is that, when the user shrinks the textbox, there is no way to view the content out of sight.当前的行为是,当用户缩小文本框时,无法查看看不见的内容。 My goal is to bring up the scroll bar when the user shrinks the text area.我的目标是在用户缩小文本区域时调出滚动条。

View CodeSandbox to test.查看CodeSandbox进行测试。

Simply add overflow: 'auto' to the style attribute.只需在样式属性中添加overflow: 'auto'

<TextareaAutosize
  minRows="2"
  style={{ width: '50%', resize: 'vertical', overflow: 'auto' }}
/>

Codesandbox 代码沙盒

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM