使用 Bootstrap 4 和 bootswatch,我想将四个 Django 表单文件since
(col-sm-2
/textinput)、until
(col-sm-2
/textinput)、currently_employed
(col-sm-7
/custom 复选框)和表单关闭按钮(col-sm-1
/ a
tag)放在一行中。
但它在自定义复选框上呈现错误(复选框位置错误):
上面的代码是:
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/4.0.0-beta.3/solar/bootstrap.min.css" rel="stylesheet" integrity="sha384-Jpv9vxZao0dlyvegpeTxSgc5cczNCOpcV5ihm8RQbrMo263QmC3Sf5HIMBfr+nqx" crossorigin="anonymous">
<div class="row-fluid">
<div class="col-sm-1 float-right">
<!-- Empty Career: Close form button -->
<a class="btn btn-default float-right close-career">
<i class="fas fa-times"></i>
</a>
</div>
<div class="col-sm-2 float-left">
<div class="form-group">
<input type="text" name="career-__prefix__-since" class="form-control" placeholder="0000.0" id="id_career-__prefix__-since" />
</div>
</div>
<div class="col-sm-2 float-left">
<div class="form-group">
<input type="text" name="career-__prefix__-until" class="form-control" placeholder="0000.0" id="id_career-__prefix__-until" />
</div>
</div>
<div class="col-sm-7">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" name="career-__prefix__-currently_employed" class="custom-control-input form-control float-left" id="id_career-__prefix__-currently_employed" />
<label class="custom-control-label" for="id_career-__prefix__-currently_employed">
Currently employed
</label>
</div>
</div>
</div>
since
和until
是float-left
,关闭按钮是float-right
。
为了看起来正确,我将类添加float-left
到currently_employed
,它看起来不错但不可点击:
更改后的代码是:
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/4.0.0-beta.3/solar/bootstrap.min.css" rel="stylesheet" integrity="sha384-Jpv9vxZao0dlyvegpeTxSgc5cczNCOpcV5ihm8RQbrMo263QmC3Sf5HIMBfr+nqx" crossorigin="anonymous">
<div class="row-fluid">
<div class="col-sm-1 float-right">
<!-- Empty Career: Close form button -->
<a class="btn btn-default float-right close-career">
<i class="fas fa-times"></i>
</a>
</div>
<div class="col-sm-2 float-left">
<div class="form-group">
<input type="text" name="career-__prefix__-since" class="form-control" placeholder="0000.0" id="id_career-__prefix__-since" />
</div>
</div>
<div class="col-sm-2 float-left">
<div class="form-group">
<input type="text" name="career-__prefix__-until" class="form-control" placeholder="0000.0" id="id_career-__prefix__-until" />
</div>
</div>
<div class="col-sm-7 float-left">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" name="career-__prefix__-currently_employed" class="custom-control-input form-control float-left" id="id_career-__prefix__-currently_employed" />
<label class="custom-control-label" for="id_career-__prefix__-currently_employed">
Currently employed
</label>
</div>
</div>
</div>
我怎样才能让它既可点击又好看?