我正在尝试在使用引导程序4时创建一个按钮,单击该按钮时该按钮将折叠成表单。我遇到的问题是,您无法编写'data-toggle =“ collapse”',因为它将覆盖“ Bootstrap Toggle” CSS,成为一个简单的复选框。我知道使用“按钮”时可能会折叠,但我希望使用“ Bootstrap Toggle”中的动画,这是一个问题,因为它使用了“输入”而不是“按钮”。我需要一个解决方案的帮助,当从“是”切换为“否”时,它会折叠成具有多个复选框的表格,这些复选框会覆盖表格的单元格。在此先感谢!
创建示例,运行代码!
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
</style>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
<!-- Toggle Switch Animation -->
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<title>Example</title>
</head>
<body>
<div class="container">
<div class="form-group">
<table class="table table-bordered" style="background: white">
<tbody>
<tr>
<th scope="row">
<p class="pt-2">Example 1 </p>
</th>
<th scope="row">
<input type="checkbox" checked data-toggle="toggle" data-toggle="dropdown-menu" data-size="small" data-on="yes" data-off="no" data-offstyle="danger">
</div>
</th>
</tr>
<tr>
<th scope="row">
<p class="pt-2">Example 2 </p>
</th>
<th scope="row">
<input type="checkbox" checked data-toggle="toggle" data-size="small" data-on="yes" data-off="no" data-offstyle="danger">
</th>
</tr>
<tr>
<th scope="row">
<p class="pt-2">Example 3 </p>
</th>
<th scope="row">
<input type="checkbox" checked data-toggle="toggle" data-size="small" data-on="yes" data-off="no" data-offstyle="danger">
</th>
</tr>
</tbody>
</table>
</div>
</div>
<!-- JS -->
<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>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
</body>
</html>