Bootstrap-自定义单选按钮



我想制作一些自定义的引导程序单选按钮
我看到了文档:https://getbootstrap.com/docs/4.0/components/buttons/#checkbox-和单选按钮

是他们的一种方式来分开按钮,使它们看起来像3个分开的按钮,而不是一个长按钮。

如果他们是这样的话——当用户选择按钮时,我能改变它的颜色吗?

谢谢!

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Bootstrap</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-primary rounded mr-1 active">
			<input type="radio" name="options" id="option1" autocomplete="off" checked=""> Active
		</label>
<label class="btn btn-success rounded mr-1">
			<input type="radio" name="options" id="option2" autocomplete="off"> Radio
		</label>
<label class="btn btn-danger rounded">
			<input type="radio" name="options" id="option3" autocomplete="off"> Radio
		</label>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>

如果你听说过"利润",是的,你可以。

您基本上是在问如何将组件用于尚未构建的东西
建议将单选按钮用作单选按钮,将普通按钮用作普通按钮

无论如何,这就是您可以做到的(多种方法之一(:
向每个按钮添加类mr-1。它将添加一些margin-right,您可以在_variables.scss文件中自定义,通过添加此类,您的按钮将被一些空间隔开。

最新更新