textareas的奇怪行为

时间:2016-07-21 02:56:24

标签: javascript html user-interface reactjs frontend

我在这种形式的textareas遇到以下问题。第一张图片在我的电脑里,表格看起来还不错,但在第二张图片中,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;
    }
  }
}

1 个答案:

答案 0 :(得分:2)

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

*但是在mac上,如果你没有插入鼠标,那么滚动条无论如何都会自动隐藏。这就是你看到不同结果的原因。

您可能希望overflow: auto只显示滚动条,如果需要的话。或者正如其中一条评论所说,你可能真的只想要一个<input>