如何写出一个规整的Form(Overview)

Overview

Here’s a quick example to demonstrate(示范) Bootstrap’s form styles. Keep reading for documentation on required(必须的) classes, form layout, and more.

A Example

  • 每个input都有一个label对应.form-control

  • 在框下有一个描述文字.form-text

  • 一个Bootstrap's style的check input .form-check-input

  • 一个Bootstrap's style的btn

        <form>
            <div class="mb-3">
              <label for="input1" class="form-label">Email</label>
              <input type="email" class="form-control" id="input1" 
              aria-describedby="emailHelp">
              <div id="emailHelp" class="form-text">
              We'll never share your email with anyone else.</div>
            </div>
            <div class="mb-3">
              <label for="input2" class="form-label">Password</label>
              <input type="password" class="form-control" id="input2">
            </div>
            <div class="mb-3 form-check">
              <input type="checkbox" class="form-check-input" id="check1">
              <label class="form-check-label" for="check1">Check me out</label>
            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
          </form>

Form text

上面的例子演示了在input框下添加描述文字,现在我希望input和text放在同一行,如何实现

**Inline text use typical inline HTML element with nothing more than **.form-text

如何实现行内文字,只需要使用那些行内特性的html标签元素并只标上form-text

  • 此处选择直接对div添加.row使其确保一行

  • 利用行内标签<span>为其添加描述文字

        <div class="row g-3 align-items-center">
            <div class="col-auto">
              <label for="pwd" class="col-form-label">Password</label>
            </div>
            <div class="col-auto">
              <input type="password" id="pwd" class="form-control" 
              aria-describedby="pwdHelp">
            </div>
            <div class="col-auto">
              <span id="pwdHelp" class="form-text">
                Must be 8-20 characters long.
              </span>
            </div>
        </div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值