我试图制作一个带有bootstrap smth的搜索栏,该栏类似于holidaypiratescom搜索字段。
我需要在第一个和最后一个按钮上具有最小宽度,同时让3个表单字段灵活显示。如果我直接使用css(min-width)设置宽度,则在我缩小屏幕时,按钮元素会粘在卡的外部。不知道该怎么做,有什么建议吗?
<div class="card">
<div class="search-box d-md-inline-flex">
<!-- col1 -->
<div class="card border-0">
<input class="btn btn-primary" type="text" name="" value="All categories">
</div>
<!-- col2 -->
<div class="card border-0">
<input class="form-control mr-2" type="text" name="departure" placeholder="Departure">
</div>
<!-- col3 -->
<div class="card border-0">
<input class="form-control mr-2" type="text" name="destination" placeholder="Destination">
</div>
<!-- col4 -->
<div class="card border-0">
<input class="form-control mr-2" type="text" name="type" placeholder="Travel Period">
</div>
<!-- Submit -->
<div class="card border-0">
<input class="btn btn-primary" type="submit" name="" value="go">
</div>
</div><!--/search-box -->
</div> <!-- /card -->
答案 0 :(得分:-1)
<div class="card container">
<div class="container">
<div class="search-box d-md-inline-flex">
<!-- col1 -->
<div class="card border-0 p-3">
<input class="btn btn-primary" type="text" name="" value="All categories">
</div>
<!-- col2 -->
<div class="card border-0 p-3">
<input class="form-control mr-2" type="text" name="departure" placeholder="Departure">
</div>
<!-- col3 -->
<div class="card border-0 p-3">
<input class="form-control mr-2" type="text" name="destination" placeholder="Destination">
</div>
<!-- col4 -->
<div class="card border-0 p-3">
<input class="form-control mr-2" type="text" name="type" placeholder="Travel Period">
</div>
<!-- Submit -->
<div class="card border-0 p-3">
<input class="btn btn-primary" type="submit" name="" value="go">
</div>
</div><!--/search-box -->
</div>
</div>
使用容器类包装内容。对于响应式,请使用lg,md,sm作为类。