Bootstrap4让两个input并排显示

1、使用.row和.col组合

<form>
  <div class="row">
    <div class="col">
      <label class="form-inline">名:
        <input type="text" class="form-control" placeholder="First name">
      </label>
    </div>
    <div class="col">
      <label class="form-inline">姓:
        <input type="text" class="form-control" placeholder="Last name">
      </label>
    </div>
  </div>
</form>

2、也可以使用 .form-row来取代.row(它们二者很多时候可以互换使用),区别是.form-row提供更小的沟槽缝隙。

<form>
  <div class="form-row">
    <div class="col">
      <label class="form-inline">名:
        <input type="text" class="form-control" placeholder="First name">
      </label>
    </div>
    <div class="col">
      <label class="form-inline">姓:
        <input type="text" class="form-control" placeholder="Last name">
      </label>
    </div>
  </div>
</form>

参考:

1、https://code.z01.com/v4/components/forms.html#form-grid

2、https://blog.csdn.net/qq_23350817/article/details/84072868

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
如果你在使用Bootstrap时,引入了两个版本的Bootstrap,可能会出现其中一个不能正常显示的情况。这是由于两个版本之间的命名空间冲突导致的。 为了解决这个问题,你可以尝试以下几种方法: 1. 只引入一个版本的Bootstrap:如果你只需要一个版本的Bootstrap,那么只需要引入其中一个即可。 2. 使用别名避免冲突:你可以为其中一个版本的Bootstrap指定一个别名,以避免与另一个版本冲突。例如: ```html <!-- 引入第一个版本的Bootstrap --> <link rel="stylesheet" href="https://cdn.example.com/bootstrap-4.3.1/css/bootstrap.min.css"> <!-- 引入第二个版本的Bootstrap,并使用别名“bootstrap2” --> <link rel="stylesheet" href="https://cdn.example.com/bootstrap-5.0.0/css/bootstrap.min.css" as="bootstrap2"> ``` 然后,在你的代码中,你可以使用“bootstrap2”别名来访问第二个版本的Bootstrap。 3. 使用命名空间避免冲突:Bootstrap 5.0.0之后,它提供了一种使用命名空间来避免冲突的方法。你可以在引入Bootstrap之前,设置一个命名空间: ```html <!-- 设置命名空间为“bs5”--> <script>window.bootstrap = {namespace: 'bs5'}</script> <!-- 引入Bootstrap 5.0.0 --> <link rel="stylesheet" href="https://cdn.example.com/bootstrap-5.0.0/css/bootstrap.min.css"> <!-- 引入Bootstrap 4.3.1 --> <link rel="stylesheet" href="https://cdn.example.com/bootstrap-4.3.1/css/bootstrap.min.css"> ``` 然后,在你的代码中,你可以使用命名空间“bs5”来访问Bootstrap 5.0.0的组件和样式。例如: ```javascript // 初始化一个模态 var modal = new bootstrap.Modal(document.getElementById('myModal'), { namespace: 'bs5' }); ``` 希望这些方法能够帮助你解决问题。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值