【问题标题】:Bootstrap 4: Vertically center anything in the middle of form-group > input elementBootstrap 4:垂直居中表单组>输入元素中间的任何内容
【发布时间】:2021-09-12 18:28:31
【问题描述】:

使用 Bootstrap 4,是否可以在输入中间垂直居中任何元素? (结构简单,div不多)

https://jsfiddle.net/fekula/8j4ew5df/9/的第一个例子或多或少不错,但第二个和第三个不好

<div class="form-row align-items-end">
   <div class="form-group col-md-7">
    <label>Name:</label>
    <input class="form-control">
  </div>
  <div class="form-group col-md-5">
    <label>
        Center text
    </label>
  </div>
</div>

有什么想法吗?谢谢。

【问题讨论】:

    标签: html css twitter-bootstrap bootstrap-4


    【解决方案1】:

    第一个标签不居中,对于没有类的标签,它只有一个默认的下边距。 例如,通过将mb-2 类添加到.custom-control.custom-switch 元素就可以了。

    但是您需要将您的input[type="text"] 放在一个带有标签的.row 元素中,以使它们垂直居中。

    【讨论】:

    • 我想垂直居中元素,没有边距。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 2014-06-28
    • 2020-06-14
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 2013-01-09
    相关资源
    最近更新 更多