Bootstrap 3复选框标签

时间:2016-05-08 08:08:50

标签: html css twitter-bootstrap-3

如何在复选框中添加标签,以便我可以将它们内联。

我想要这样:

label input input

目前,以下代码显示为input input label为什么?

HTML:

   <div class="col-md-6 pull-right">
        <div class="form-group">
            <label>Gender</label> <label class=
            "col-sm-2 checkbox-inline"><input id="genMale" type="checkbox"
            value="genMale">Male</label> <label class=
            "col-sm-2 checkbox-inline"><input id="genFemale" type=
            "checkbox" value="genFemale">Female</label> 
        </div>

5 个答案:

答案 0 :(得分:1)

gender标签不在网格内。将类col-sm-2添加到标签。

<label class="col-sm-2">Gender</label>

JSFIDDLE

答案 1 :(得分:0)

this是你需要的吗?或者我错了? 你有拉右,我删了它

<div class="col-md-6">

答案 2 :(得分:0)

你可以试试这个。

<label style="float:left;margin-right:15px;">Gender</label>

你也可以尝试这个....

<label class="pull-left">Gender</label> 

答案 3 :(得分:0)

你可以这样做。我认为这对你来说非常有用。

快乐编码:-); - )

&#13;
&#13;
    <!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2>Inline Check Box</h2>
  <form class="form-inline" role="form">
    <div class="checkbox">
     <label>Gender</label> 
     </div>
     
    <div class="checkbox">
      <label> Male <input type="checkbox"></label>
    </div>
    
     <div class="checkbox">
      <label> Female <input type="checkbox"></label>
    </div>
   
  </form>
</div>

</body>
</html>
&#13;
&#13;
&#13;

答案 4 :(得分:0)

MB你的意思是这样的吗?

&#13;
&#13;
 <div class="col-md-6 pull-right">
        <div class="form-group">
            <label>Gender</label> <br><br>
          
            <input id="genMale" type="checkbox"  value="genMale" name="male">
            <label for="male" class="col-sm-2 checkbox-inline">Male</label>
            <input id="genFemale" type="checkbox" value="genFemale" name="Female">
            <label for="Female" class="col-sm-2 checkbox-inline">Female</label> 
</div>
&#13;
&#13;
&#13;

相关问题