0

我使用 bootstrap 4 如何在同一行中折叠?

这是我的html

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">

<div id="accordion2" role="tablist" aria-multiselectable="true">

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne2">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-target="#collapseOne2" data-parent="#accordion2" href="#" aria-expanded="true" aria-controls="collapseOne2">
              Collapsible Group Item #1
            </a>
      </h4>
    </div>
    <div id="collapseOne2" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne2">
      body 1
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo2">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-target="#collapseTwo2" data-parent="#accordion2" href="#" aria-expanded="false" aria-controls="collapseTwo2">
              Collapsible Group Item #2
            </a>
      </h4>
    </div>
    <div id="collapseTwo2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo2">
      body 2
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingThree2">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-target="#collapseThree2" data-parent="#accordion2" href="#" aria-expanded="false" aria-controls="collapseThree2">
              Collapsible Group Item #3
            </a>
      </h4>
    </div>
    <div id="collapseThree2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree2">
      body 3
    </div>
  </div>

</div>

我想现在它显示

可折叠组项目 #1

可折叠组项目 #2

可折叠组项目 #3

我怎么能像这样把它们分组

可折叠组项目 #1 可折叠组项目 #2 可折叠组项目 #3

4

1 回答 1

2

只需添加以下css

.panel-default{
  display : flex;

}

工作片段在这里。

   /* .panel-default{
display : flex;
} */
#accordion2{ display: flex}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">

<div id="accordion2" role="tablist" aria-multiselectable="true">

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne2">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-target="#collapseOne2" data-parent="#accordion2" href="#" aria-expanded="true" aria-controls="collapseOne2">
              Collapsible Group Item #1
            </a>
      </h4>
    </div>
    <div id="collapseOne2" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne2">
      body 1
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo2">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-target="#collapseTwo2" data-parent="#accordion2" href="#" aria-expanded="false" aria-controls="collapseTwo2">
              Collapsible Group Item #2
            </a>
      </h4>
    </div>
    <div id="collapseTwo2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo2">
      body 2
    </div>
  </div>

  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingThree2">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-target="#collapseThree2" data-parent="#accordion2" href="#" aria-expanded="false" aria-controls="collapseThree2">
              Collapsible Group Item #3
            </a>
      </h4>
    </div>
    <div id="collapseThree2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree2">
      body 3
    </div>
  </div>

</div>

于 2018-01-16T09:31:02.450 回答