0

我需要将标签和输入放在一行上。

<div class="container">
  <div class="row mt-2">
    <div class="form-group">
      <div class="dates">
        <label class="d-inline-block" for="arrival">Дата заезда:</label>
        <div class="col-10">
          <input type="text" class="form-control form-control-sm d-inline-block" name="arrival" id="arrival" placeholder="YYYY-MM-DD" autocomplete="off" required>
        </div>
      </div>
    </div>
  </div>
</div>

现在的样子:

在此处输入图像描述

4

3 回答 3

1

那这个呢?

<div class="container">
        <div class="row mt-2">
            <div class="form-group">
                <div class="dates">
                    <div class="col-6">
                        <label class="d-inline-block" for="arrival">Label:</label>
                    </div>
                    <div class="col-6">
                        <input type="text" class="form-control form-control-sm d-inline-block" name="arrival"
                               id="arrival" placeholder="YYYY-MM-DD" autocomplete="off" required>
                    </div>
                </div>
            </div>
        </div>
    </div>
于 2019-04-02T05:48:33.427 回答
1

一种解决方案可能是使用rowcol-*类,如此处所述

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

<div class="container">
<form>
  <div class="form-group">
  <div class="dates row">
    <label class="col-auto" for="arrival">Дата заезда:</label>
    <div class="col">
      <input type="text" class="col form-control form-control-sm" name="arrival" id="arrival" placeholder="YYYY-MM-DD" autocomplete="off" required>
    </div>
  </div>
  </div>
</form>
</div>

于 2019-04-02T06:13:05.227 回答
0

要使其显示内联块,您需要设置包含输入的 div 样式,而不是输入本身。它应该是这样的:

<div class="container">
                <div class="row mt-2">
                    <div class="form-group">
                        <div class="dates">
                            <label class="d-inline-block" for="arrival">Дата заезда:</label>
                            <div class="col-10 d-inline-block">
                                <input type="text" class="form-control form-control-sm" name="arrival"
                                       id="arrival" placeholder="YYYY-MM-DD" autocomplete="off" required>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
于 2019-04-02T06:03:09.510 回答