无法设置单选按钮引导程序?

时间:2015-11-21 13:32:53

标签: javascript jquery html css twitter-bootstrap

我添加了内联样式表来为两个单选按钮着色,但两个单选按钮保持蓝色,它们不会变为红色或绿色。 这是代码,你能帮我找一下代码中的错误吗?

     <!DOCTYPE html>
<html lang="en">

<head>
	 <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head 
         content must come *after* these tags -->
    <title>Ristorante Con Fusion</title>
       <!-- Bootstrap -->
     
      <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-theme.min.css" rel="stylesheet">
       <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/bootstrap-social.css" rel="stylesheet">
    <link href="css/mystyles.css" rel="stylesheet">
    </head>
    <body> <form class="form-horizontal" role="form">

<div class="form-group">
			          <label for="btn-group" class="col-xs-12 col-sm-2 control-label">Sections</label>

        <div class="btn-group" data-toggle="buttons">
  <label class="btn btn-primary active">
    <input type="radio" name="options" id="option1" autocomplete="off" style ="background-color:red;" checked > True
  </label>
         
  <label class="btn btn-primary">
    <input type="radio" name="options" id="option3" style="background-color: green;" autocomplete="off"> False
  </label>
</div></div>
</form><!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script>
        $(document).ready(function(){
        $('[data-toggle="tooltip"]').tooltip();
         });
    </script>

</body>

</html>
</body>

     </html>

2 个答案:

答案 0 :(得分:3)

将班级btn-primary更改为btn-success变为绿色,btn-danger变为红色

答案 1 :(得分:1)

您正在设置单选按钮本身的样式,但使按钮变为蓝色的是包含它的标签。试试这个

 <label class="btn btn-primary active" style ="background-color:red;">
    <input type="radio" name="options" id="option1" autocomplete="off" checked > True
  </label>

  <label class="btn btn-primary" style="background-color: green;">
    <input type="radio" name="options" id="option3" autocomplete="off"> False
  </label>