文本区域的奇怪行为

Strange behavior with textareas

我在使用此表单中的文本区域时遇到以下问题。第一张图片在我的电脑上,表格看起来还不错,但是在第二张图片中,文本区域看起来很奇怪。我想知道造成这种行为的原因是什么,以及我该如何改进。

html

<div className="information-wrapper col-md-12 col-sm-12 col-xs-12">
  <div className="icon-container col-md-3 col-sm-3 col-xs-3">
    <img src="/name-image.png"/>
  </div>
  <div className="text-container col-md-9 col-sm-9 col-xs-9">
    <textarea className="information-textarea" placeholder={I18n.t('name')} />
  </div>
</div>

css

.information-wrapper{
  padding-right: 0;
  padding-left: 0;
  width: 100%;
  height: 51px;
  border-radius: 4px;
  background-color: #ffffff;
  margin-bottom: 10px;
  .icon-container{
    max-width: 53.65px;
    padding-right: 0;
    padding-left: 0;
    height: 51px;
    border-right: 0.5px solid #e7e5e8;
    text-align: center;
    img{
      margin-top: 15px;
      width: 22px;
      height: auto;
      -webkit-filter: grayscale(100%);
      filter: grayscale(100%);
    }
  }
  .text-container{
    padding-right: 0;
    padding-left: 0;
    height: 51px;
    .information-textarea{
      height: 95%;
      width: 100%;
      font-size: 17px;
      font-weight: bold;
      padding-left: 5.5px;
      padding-top: 15px;
      border: 0;
      border-radius: 4px;
      resize: none;
      white-space: nowrap;
      overflow-x: scroll;
    }
  }
}

overflow: scroll 将始终显示滚动条*,即使不需要它们也是如此。

*但是在 Mac 上,如果您没有插入鼠标,滚动条会自动隐藏。这就是您看到不同结果的原因。

您可能需要 overflow: auto,它只会在需要时显示滚动条。或者正如其中一条评论所说,您可能真的只想要一个 <input>.