可以't型单选按钮引导程序

Can't style radio buttons bootstrap?

本文关键字:单选按钮 引导程序 可以      更新时间:2023-09-26

我添加了内联样式表来给这两个单选按钮上色,但这两个按钮仍然是蓝色的,它们没有变成红色或绿色。这就是代码,你能帮我找到代码中的错误吗?

     <!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>

将类btn-primary更改为btn-success,使其变为绿色,将btn-danger更改为红色

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

 <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>