如何将标签移动到Bootstrap 3中复选框的左侧? [英] How can I move a label to the left of a checkbox in Bootstrap 3?

查看:185
本文介绍了如何将标签移动到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>

UPDATED EXAMPLE HERE

这篇关于如何将标签移动到Bootstrap 3中复选框的左侧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆