【问题标题】:How can I create an input with text at top instead of centered如何在顶部而不是居中创建文本输入
【发布时间】:2020-01-22 08:02:13
【问题描述】:

如何让文本从顶部开始而不是从中间开始?

<input class="card card-experience">
.card-experience{
    width: 600px;
    height: 100px;
    position: absolute;
    padding-bottom: 22px;
    top: 400px;
    border-color: black;
    box-sizing: border-box;
}

【问题讨论】:

  • 请添加有关您的问题的更多详细信息。
  • 我不知道我能说清楚多少,然后我已经做了什么。

标签: html css bootstrap-4


【解决方案1】:
  1. input type="text" 用于单行文本。

  2. 您可以改用“textarea”,根据输入元素的大小,您似乎想要进行大输入或允许输入大量行。 "textarea" 将允许您这样做,同时文本从左上角开始。

参考:https://www.w3schools.com/tags/tag_textarea.asp

如果您使用“textarea”并且不想要滚动条,请参考:

Remove scrollbars from textarea

【讨论】:

    【解决方案2】:

    以下可能满足您的要求。移除 padding-bottom 并将输入标签更改为 textarea

        .card-experience {
            width: 600px;
            height: 100px;
            position: absolute;
            top: 400px;
            border-color: black;
            box-sizing: border-box;
        }
    
        <textarea class="card card-experience"></textarea>
    

    注意:当你想在多行中输入数据时,input标签应该改为textarea标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-14
      • 2014-10-25
      • 1970-01-01
      • 2020-11-06
      • 2023-01-12
      • 2015-08-02
      • 2018-01-23
      • 2015-10-25
      相关资源
      最近更新 更多