如何将标签移动到Bootstrap 3中复选框的左侧? [英] How can I move a label to the left of a checkbox in Bootstrap 3?
问题描述
我正在使用
< div class =col -xs-4 col-sm-3 col-md-2 col-md-offset-2 everything-checkbox>
< div class =checkbox>
< label>
< input type =checkboxclass =checkbox style-2checked =checked>
< span>文字转到此处< / span>
< / label>
< / div>
我曾尝试将跨度放在顶部,而且这也不起作用,那么如果我做到了一个空白的复选框,只是把文本放在前面,然后他们不排队。
任何帮助将非常感激。
.radio input [type =radio],
.radio-inline input [type =radio],
.checkbox input [type =checkbox],
.checkbox-inline input [type =checkbox] {
float:left;
margin-left:-20px;
code $ $ $ $ $ $ $ $ $ $ $ $ $ $ $为了解决这个问题,你可以简单地添加 输入
元素的类: >< input type =checkboxid =checkbox1class =checkbox style-2 pull-rightchecked =checked/>
值得注意的是标签
元素应该的属性匹配输入元素的 id
属性,如下所示:
< div class =checkbox>
< label for =checkbox1>
< span>文字转到此处< / span>
< / label>
< input type =checkboxid =checkbox1class =checkbox style-2 pull-rightchecked =checked/>
< / div>
Is there anyway to get the text of a checkbox to be on the left side of the checkbox? I have tried and tried but cant get it working.
I'm using
<div class="col-xs-4 col-sm-3 col-md-2 col-md-offset-2 everything-checkbox">
<div class="checkbox">
<label>
<input type="checkbox" class="checkbox style-2 " checked="checked">
<span>Text goes here</span>
</label>
</div>
I have tried putting the span on top and that also doesn't work, Then if I make it a blank checkbox and just put text in front then they don't line up.
any help would be really appreciated.
Bootstrap styling will float the checkbox
elements to the left because of this styling:
.radio input[type="radio"],
.radio-inline input[type="radio"],
.checkbox input[type="checkbox"],
.checkbox-inline input[type="checkbox"] {
float: left;
margin-left: -20px;
}
To solve this, you could simply add pull-right
to the input
element's class:
<input type="checkbox" id="checkbox1" class="checkbox style-2 pull-right" checked="checked"/>
It's also worth noting that a label
element should have a for
attribute matching the input element's id
attribute, like this:
<div class="checkbox">
<label for="checkbox1">
<span>Text goes here</span>
</label>
<input type="checkbox" id="checkbox1" class="checkbox style-2 pull-right" checked="checked"/>
</div>
这篇关于如何将标签移动到Bootstrap 3中复选框的左侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!