【问题标题】:Strange behavior with textareastextareas 的奇怪行为
【发布时间】:2016-11-24 10:47:25
【问题描述】:

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

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;
    }
  }
}

【问题讨论】:

  • 分享两个内容的代码,否则小提琴会有所帮助
  • 为什么你使用textarea 来做这些输入?其中大多数是简短的单行输入,您应该使用&lt;input type="text"&gt;。
  • 我猜我的错,没想太多。
  • 为什么不直接隐藏溢出

标签: javascript html user-interface reactjs frontend


【解决方案1】:

overflow: scroll 将始终显示滚动条*,即使它们不是必需的。

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

您可能想要overflow: auto,它只会在需要时显示滚动条。或者正如其中一位 cmets 所说,您可能真的只是想要一个 &lt;input&gt;。

【讨论】:

    猜你喜欢
    • 2015-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-08
    • 2015-07-20
    • 2010-10-03
    • 2021-07-12
    • 2013-10-04
    相关资源
    最近更新 更多