使用引导程序内联两个元素

时间:2019-05-22 07:39:52

标签: css twitter-bootstrap css3 bootstrap-4

我正在练习我的自举技能,但由于某种原因我陷入了内联输入和选择的困境

这是我想要的输出

enter image description here

但是我以某种方式得到了

enter image description here

使用此代码

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-2">
  <label>Length of Stay</label>
  <div class="form-group d-inline">
    <input type="text" class="form-control">
    <select class="custom-select">
      <option disabled selected>Select Length</option>
      <option value="Years">Years</option>
      <option value="Months">Months</option>
      <option value="Days">Days</option>
    </select>
  </div>
</div>

你知道我该如何解决吗?

1 个答案:

答案 0 :(得分:1)

将引导程序类d-flex添加到form-group。谢谢

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-2">
  <label>Length of Stay</label>
  <div class="form-group d-flex">
    <input type="text" class="form-control">
    <select class="custom-select">
      <option disabled selected>Select Length</option>
      <option value="Years">Years</option>
      <option value="Months">Months</option>
      <option value="Days">Days</option>
    </select>
  </div>
</div>