React文本输入框 – overflow-y未显示滚动条(在Chrome或Edge上)

huangapple go评论84阅读模式
英文:

React Textarea Input - overflow-y is not showing scrollbar (on Chrome or Edge)

问题

我似乎无法弄清楚如何在React Textarea中显示/添加滚动条。我已参考了这篇旧帖子https://stackoverflow.com/questions/7855590/preventing-scroll-bars-from-being-hidden-for-macos-trackpad-users-in-webkit-blin和其他一些帖子,但都没有成功。

我在Chrome(版本113.0.5672.129)和Edge(版本114.0.1823.37)中进行了测试。

这是我的代码:

const myComponet = () => {
  return (
    <textarea className={styles.largeTextBox} id="someTextBox"></textarea>
  );
}

// 样式表
.largeTextBox {
  width: 200px;
  height: 50px;
  overflow-x: hidden;
  overflow-y: scroll;
}

.largeTextBox::-webkit-scrollbar {
  width: 11px;
}

.largeTextBox::-webkit-scrollbar-track {
  background-color: #fff;
  border-radius: 8px;
}

非常感谢您的帮助。

英文:

I can't seem to figure out how to show/add scrollbar to a React Textarea. I have referenced this old post here https://stackoverflow.com/questions/7855590/preventing-scroll-bars-from-being-hidden-for-macos-trackpad-users-in-webkit-blin and few others but have not been successful.

I have tested it in both Chrome (Version 113.0.5672.129) and Edge (Version 114.0.1823.37)

Here is what I have:

const myComponet = () =&gt; {

 return (
    &lt;input type= &quot;textarea&quot; className={styles.largeTextBox} id=&quot;someTextBox&quot;/&gt;
   )
}

//Stylesheet
.largeTextBox{
  width: 200px;
  height : 50px;
  overflow-x:hidden;
  overflow-y:scroll;
}

.frame::-webkit-scrollbar:vertical{
  width:11px;
}

.frame-webkit-scrollbar-track{
  background-color: #fff;
  border-radius: 8px;
}

Really appreciate some help here.

答案1

得分: 0

&quot;textarea&quot; 不是&lt;input&gt;的有效类型。您需要使用&lt;textarea&gt;元素代替。

&lt;textarea className={styles.largeTextBox} id=&quot;someTextBox&quot; /&gt;
英文:

&quot;textarea&quot; is not a valid type for an &lt;input&gt;. You want a &lt;textarea&gt; element instead.

&lt;textarea className={styles.largeTextBox} id=&quot;someTextBox&quot; /&gt;

huangapple
  • 本文由 发表于 2023年6月5日 04:46:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76402349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定