html 手风琴风格显示隐藏内容 - 可能的解决方案

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 手风琴风格显示隐藏内容 - 可能的解决方案相关的知识,希望对你有一定的参考价值。

<!-- Using jQuery UI Widget: Accordion -->
<head>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script>
    $(function() {
      $( "#accordion" ).accordion();
    });
  </script>
</head>
<body>
  <div id="accordion">
  <h3>Section 1</h3>
  <div>
    <p>
      Text for Section 1
    </p>
  </div>
  <h3>Section 2</h3>
  <div>
    <p>
      Text for Section 2
    </p>
  </div>
  <h3>Section 3</h3>
  <div>
    <p>
      Text for Section 3
    </p>
  </div>
  <h3>Section 4</h3>
  <div>
    <p>
      Text for Section 4
    </p>
  </div>
</div>
</body>
<!-- This example uses Bootstrap data-toggle attribute
You can use a link with the href attribute, or a button with the data-target attribute. In both cases, the data-toggle="collapse" is required.
-->


<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
  Link with href
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
  Button with data-target
</button>
<div class="collapse" id="collapseExample">
  <div class="well">
    Some text here
    <br>
    More text here
  </div>
</div>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
        <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
          Collapsible Group Item #1
        </a>
      </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
      <div class="panel-body">
       Content for panel 1
      </div>
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
          Collapsible Group Item #2
        </a>
      </h4>
    </div>
    <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
      <div class="panel-body">
        Content for panel 2
      </div>
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingThree">
      <h4 class="panel-title">
        <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
          Collapsible Group Item #3
        </a>
      </h4>
    </div>
    <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
      <div class="panel-body">
        Content for panel 3
      </div>
    </div>
  </div>
</div>

以上是关于html 手风琴风格显示隐藏内容 - 可能的解决方案的主要内容,如果未能解决你的问题,请参考以下文章

JS实现手风琴效果

显示/隐藏以作为手风琴工作

HTML页面大小显示问题,超出自动隐藏

如何在 SwiftUI 的 ScrollView 中制作动画? SwiftUI 中的手风琴风格动画

当 div 显示/父级处于活动状态时,将 aria-hidden 切换为 false

手风琴的音乐风格