我需要将标签和输入内容放在一行上。
<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>
现在的样子:
答案 0 :(得分: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>
答案 1 :(得分:0)
一种解决方案可能是使用here类的row
和col-*
类
<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>
答案 2 :(得分:-1)
那呢?
<div class="container">
<div class="row mt-2">
<div class="form-group">
<div class="dates">
<div class="col-10">
<label class="d-inline-block" for="arrival">Label:</label>
</div>
<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>