Twitter bootstrap 引导窗体未折叠

Twitter bootstrap 引导窗体未折叠,twitter-bootstrap,forms,Twitter Bootstrap,Forms,试图在表单中使用引导折叠,但它没有响应。直接从引导程序网站复制粘贴,但仍然不起作用。请帮忙 <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" data-target="firstname" aria-expanded="false" aria-controls="collapseExample"> Test </a> <form>

试图在表单中使用引导折叠,但它没有响应。直接从引导程序网站复制粘贴,但仍然不起作用。请帮忙

<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" data-target="firstname" aria-expanded="false" aria-controls="collapseExample">
   Test
 </a>
<form>
  <div class="form-row mb-1 collapse" id="firstname">
    <div class="form-group col-md-6">
      <input type="email" class="form-control" placeholder="Legal first name">
    </div>
  </div>
  <div class="form-group col-md-6">
    <input type="password" class="form-control" id="inputPassword4" placeholder="Legal last name">
  </div>
</div>
  </form>

您缺少要切换的元素中的
id=“collapseExample”
数据目标=“#collapseExample”

怎么会这样?我要触发折叠的元素(btn)用数据目标指示,我要切换的元素(表单行)用id指示。这正是引导程序在您提供的链接中布局代码的方式。因为
id
是最重要的,我猜引导程序使用了
collapse
css类进行样式设置,但是如果您还检查了另一个示例,您可以看到,如果您删除
class=“collapse”
,它将起作用。因此,请添加
data target=“#demo”
id=“demo”
,然后使用
class='collapse'
添加
data toggle=“collapse”
——您试图实现的目标非常简单。我建议你多学习,多做实验。你的病例中没有胶原蛋白样本id。你没有正确使用它