【问题标题】:Placing the label of the form center in twitter bootstrap在 twitter bootstrap 中放置表单中心的标签
【发布时间】:2013-03-23 14:10:18
【问题描述】:

我对 twitter bootstrap 很陌生,我正在努力将我的表单放在中心位置。

我这里有这样的代码:

<div class="row">
  <div class="pagination-centered">
        <br/><br/><br/><br/>
        <form action="/payment-init" method="POST">
          <fieldset>
            <legend>Merchant CheckOut Page</legend>
            <label>Product Name</label>
            <input type="text" placeholder="Type something..." name="productName" value="Samsung Mobile Phone"/>
            <label>Amount</label>
            <input type="text" placeholder="Enter the amount in rupees..." name="amount" required="true" />
            <label>Merchant Name</label>
            <input type="text" placeholder="Merchant name" name="merchantId" required = "true" />
            <label>Customer Email</label>
            <input type="text" placeholder="test@gmail.com" name="email" required = "true" />
            <br>
            <button type="submit" class="btn">Submit</button>
          </fieldset>
        </form>
  </div>
</div>

它的输出如下所示:

我希望将label(即产品名称、金额等)移动到文本框的左上角。这可能吗?

提前致谢。

【问题讨论】:

    标签: html css forms twitter-bootstrap


    【解决方案1】:

    尝试float: left; text-align: left; 如果这对在帖子中添加一些 CSS 代码没有帮助 :) 我无法告诉修复表单该屏幕截图 :)

    【讨论】:

      【解决方案2】:

      要将标签放置在每个文本框的左上角,您还需要使每个文本框填满所有可用宽度。因此,请执行以下操作:

      .pagination-centered label {
        text-align:left;
      }
      
      .pagination-centered input {
        width: 100%;
      }
      

      【讨论】:

        猜你喜欢
        • 2012-05-08
        • 2015-05-14
        • 2014-03-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-17
        • 1970-01-01
        相关资源
        最近更新 更多