Bootstrap 4:左侧的复选框文本,右侧的复选框

时间:2017-07-13 09:33:34

标签: css twitter-bootstrap checkbox bootstrap-4

看起来很简单,但我似乎无法弄明白。我有一个带文字的复选框,我需要文本站在左边,右边是复选框。我怎么能这样做?

这是我的代码:



.custom-control-description {
  color: #009fff;
  text-transform: uppercase;
}
.custom-checkbox .custom-control-indicator {
  border-radius: 0;
  border: 2px solid #cdc9ca;
  background: #fff;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<form>
<div class="checkbox-wrap d-flex justify-content-end p-2 mb-2">
  <label class="custom-control custom-checkbox">
    <span class="custom-control-description">All Pages</span>
  <input type="checkbox" class="custom-control-input">
    <span class="custom-control-indicator"></span>
</label>
</div>
</form>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

将位置属性添加到custom-control-indicator

的样式中
 .custom-checkbox .custom-control-indicator {
    position: relative;
    border-radius: 0;
    border: 2px solid #cdc9ca;
    background: #fff;
 }

答案 1 :(得分:-1)

尝试下面的代码,只需将文本放在标签

<label >
    <span>Text goes here....</span>
</label>
<input type="checkbox" class="custom-control-input">