当前位置: 首页 > 知识库问答 >
问题:

Bootstrap4:手风琴崩溃不顺利

陆信瑞
2023-03-14

我在bootstrap 4中制作了手风琴折叠。它可以工作,但不流畅有人知道如何解决这个问题吗?我尝试制作另一个div并将div放在里面,但什么都没有。这是代码。谢谢!

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

<section>
  <div class="container-fluid bg-light ">
    <div id="accordion">
      <div class="text-center pt-5 pb-4 mt-5 pt-4">
        <h2 id="price">Our prices</h2>
        <p> Lorem ipsum dolor, sit amet consectetur adipisicing.</p>
      </div>
      <div id="myGroup" class="d-flex align-items-center pt-4 justify-content-center flex-md-row flex-wrap">
        <div class="d-flex flex-column col-md-4 col-lg-3 ">
          <a href="#classy" data-toggle="collapse" aria-controls="classy" id="button" class="btn btn-outline-warning btn-lg mb-3" aria-expanded="true">Classy</a>
          <a href="#casual" data-toggle="collapse" aria-controls="casual" id="button" class="btn btn-outline-warning btn-lg mb-3 collapsed" aria-expanded="false">Casual</a>
          <a href="#jackets" data-toggle="collapse" aria-controls="jackets" id="button" class="btn btn-outline-warning btn-lg mb-3 collapsed" aria-expanded="false">Jacket</a>
        </div>
        <div id="classy" class="collapse show card col-md-4 col-lg-3 px-0 ml-4 my-5 " data-parent="#accordion">
          <ul class="list-group list-group-flush cards" id="cards">
            <li class="list-group-item">Suit</li>
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        </div>
        <div id="casual" class="collapse card col-md-4 col-lg-3 px-0 ml-4 my-5" data-parent="#accordion">
          <ul class="list-group list-group-flush cards" id="cards">
            <li class="list-group-item">farmerki...........</li>
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        </div>
        <div id="jackets" class="collapse card col-md-4 col-lg-3 px-0 ml-4 my-5" data-parent="#accordion">
          <ul class="list-group list-group-flush cards" id="cards">
            <li class="list-group-item">jakna...........</li>
            <li class="list-group-item">Cras justo odio</li>
            <li class="list-group-item">Dapibus ac facilisis in</li>
            <li class="list-group-item">Vestibulum at eros</li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</section>

共有1个答案

施学
2023-03-14

请你可以尝试使用这是纯引导4手风琴这是非常顺利,但

css lang-css prettyprint-override">#accordion .collapsing {
    transition: height 1s ease-in-out;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

<section>
  <div class="container-fluid bg-light ">
    <div id="accordion">
      <div class="text-center pt-5 pb-4 mt-5 pt-4">
        <h2 id="price">Our prices</h2>
        <p> Lorem ipsum dolor, sit amet consectetur adipisicing.</p>
      </div>
      <div id="accordion">
        <div class="row">
          <div class="col-6">
            <div class="card">
              <div class="card-header">
                <h5 class="mb-0">
                  <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                    Collapsible Group Item #1
                  </button>
                </h5>
              </div>
            </div> 
            <div class="card">
              <div class="card-header">
                <h5 class="mb-0">
                  <button class="btn btn-link" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
                    Collapsible Group Item #1
                  </button>
                </h5>
              </div>
            </div> 
            <div class="card">
              <div class="card-header">
                <h5 class="mb-0">
                  <button class="btn btn-link" data-toggle="collapse" data-target="#collapseThree" aria-expanded="true" aria-controls="collapseThree">
                    Collapsible Group Item #1
                  </button>
                </h5>
              </div>
            </div>
          </div>
          <div class="col-6">
              <div class="card">
                <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
                  <div class="card-body">
                    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                  </div>
                </div>

                <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
                  <div class="card-body">
                    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                  </div>
                </div>
                <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
                  <div class="card-body">
                    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
                    </div>
                  </div>
               </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
 类似资料:
  • 手风琴效果其实就是通过JS改变元素的height,然后加上transition来让css动起来。 准备HTML结构 这里我们使用 dl , 因为 dt 刚好可以模拟标题, dd 模拟内容。 <div class="panel"> <dl> <dt>One Item</dt> <dd>One Item Content .</dd>

  • 我正在使用jQuery手风琴来隐藏一些数据。 accordion标题是一个带有一些标题的表格。有一个标题,我不希望你点击它,因为手风琴事件会触发。 所以 手风琴是可折叠的,如果您单击Test2(类nofunction),手风琴事件不应触发。但是如果您单击Test或其他表头,手风琴应该会触发事件。 我可以添加这个功能吗? 更新测试http://jsfiddle.net/e3Q8d/,包括jQuery

  • jQueryUI中的Accordion Widget是一个基于jQuery的可扩展和可折叠内容持有者,它被分成几个部分,可能看起来像标签。 jQueryUI提供了accordion()方法来实现这一点。 语法 (Syntax) accordion()方法可以使用两种形式 - $(selector,context).accordion(options)方法 $(selector, context).

  • 描述 (Description) 手风琴是一个图形控制元素,显示为堆叠的项目列表。 每个手风琴都可以expanded或stretched以显示与手风琴相关的内容。 可折叠布局 当您使用单个单独的可折叠元素时,您需要省略accordion-list包装元素。 以下是可折叠布局的结构 - <!-- Single collapsible element ------> <div class = "acc

  • 在垂直导航中,如果存在多个分级,常常使用手风琴导航,它会以手风琴方式展开和折叠,来节约空间。 简单的说,手风琴导航就是垂直导航的层层嵌套,需要多少级,就嵌套多少层。这里就以两级导航为例,来介绍手风琴导航的基本制作方法。 为了方便控制手风琴导航的样式和行为,外层导航使用定义列表 dl、而内层使用无序列表 ul 来包裹导航中的链接元素: <dl class="accordion">     <dt>

  • 在Primefaces showcase上,左侧菜单上有一个搜索输入。菜单看起来像一个手风琴面板,每个键向上都会触发某种ajax来过滤手风琴选项卡。 他们是如何做到这一点的?我查看了他们的展示案例,但只看到DataTable的类似示例,而没有看到AccordionPanel的任何示例。